Created
January 5, 2012 16:29
-
-
Save levinotik/1565994 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define IN 1 | |
#define OUT 0 | |
int main(int argc, char *argv[]) { | |
int arg; | |
for(arg = 0; arg < argc; arg++) { | |
puts(argv[arg]); | |
} | |
int c, wc, cc, lines, state; | |
state = OUT; | |
wc = cc = lines = 0; | |
while((c = getchar()) != EOF) { | |
+cc; | |
if(c == '\n') | |
++lines; | |
if(c == ' ' || c == '\n' || c == '\t') | |
state = OUT; | |
else if (state == OUT) { | |
state = IN; | |
++wc; | |
} | |
} | |
printf("%d %d %d\n", lines, wc, cc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment