Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #define MAX(a, b) a < b ? b : a
- int main() {
- int max = 0, words = 0, lWords = 0;
- for (char ch, last = ' '; (ch = getchar()) != EOF; last = ch) {
- if (isspace(last) && !isspace(ch)) {
- ch = toupper(ch);
- lWords++;
- }
- if (ch == '\n') {
- max = MAX(max, lWords);
- words += lWords;
- lWords = 0;
- }
- putchar(ch);
- }
- printf("%d %d\n", words, max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement