Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- int main ()
- {
- char string[60];
- const char end[4] = "END";
- int i, j, nr = 0, chars = 0, words = 0;
- do { scanf("%s", string);
- if(strcmp(string, end) == 0)
- break;
- }
- while(1)
- int OK = 0;
- if(string[0] == '-'){
- for(i = 1; i < strlen(string); i++){
- if(isdigit(string[i]) > 0 && string[i] != 0)
- j++;
- }
- if(j == strlen(string) - 2){
- nr++;
- OK = 1;
- }
- }
- else {
- for(i = 0; i < strlen(string); i++){
- if(isdigit(string[i]) != 0 && string[i] != 0)
- j++;
- }
- if(j == strlen(string) - 1){
- nr++;
- OK = 1;
- }
- }
- if(OK == 0)
- {
- if(isdigit(string[0]) == 0 && string[1] == '\0')
- chars++;
- else words++;
- }
- }
- printf("%d %d %d\n", words, chars, nr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement