Advertisement
STANAANDREY

pc8 last ex

Nov 16th, 2022 (edited)
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define MAX(a, b) a < b ? b : a
  4.  
  5. int main() {
  6.   int max = 0, words = 0, lWords = 0;
  7.   for (char ch, last = ' '; (ch = getchar()) != EOF; last = ch) {
  8.     if (isspace(last) && !isspace(ch)) {
  9.       ch = toupper(ch);
  10.       lWords++;
  11.     }
  12.     if (ch == '\n') {
  13.       max = MAX(max, lWords);
  14.       words += lWords;
  15.       lWords = 0;
  16.     }
  17.     putchar(ch);
  18.   }
  19.   printf("%d %d\n", words, max);
  20.   return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement