home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pascal / tests / cntchars.p < prev    next >
Text File  |  1980-02-17  |  682b  |  24 lines

  1. program countcharacters(input,output);
  2.   var ch: char;
  3.     c0,c1,c2,c3,c4: integer;  {counters}
  4. begin writeln(wallclock); { linelimit(output, -1); }
  5.   c0 := 0; c1 := 0; c2 := 0; c3 := 0; c4 := 0;
  6.   while not eof(input) do
  7.   begin write(' '); c0 := c0+1;
  8.     while not eoln(input) do
  9.     begin read(ch); write(ch);
  10.       if ch = ' ' then c1 := c1+1 else
  11.       if ch in ['a'..'z'] then c2 := c2+1 else
  12.       if ch in ['0'..'9'] then c3 := c3+1 else c4 := c4+1
  13.     end ;
  14.     readln; writeln
  15.   end ;
  16.   writeln(wallclock);
  17.   writeln(c0,' lines');
  18.   writeln(c1,' blanks');
  19.   writeln(c2,' letters');
  20.   writeln(c3,' digits');
  21.   writeln(c4,' special characters');
  22.   writeln(wallclock)
  23. end .
  24.