Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5.  
  6. int main ()
  7. {
  8.     char string[60];
  9.     const char end[4] = "END";
  10.     int i, j, nr = 0, chars = 0, words = 0;
  11.             do { scanf("%s", string);
  12.  
  13.                 if(strcmp(string, end) == 0)
  14.                 break;
  15.         }
  16.         while(1)
  17.             int OK = 0;  
  18.             if(string[0] == '-'){
  19.                 for(i = 1; i < strlen(string); i++){
  20.                     if(isdigit(string[i]) > 0 && string[i] != 0)
  21.                         j++;
  22.                 }  
  23.                 if(j == strlen(string) - 2){
  24.                     nr++;
  25.                     OK = 1;
  26.                 }  
  27.             }  
  28.             else {
  29.                 for(i = 0; i < strlen(string); i++){
  30.                     if(isdigit(string[i]) != 0 && string[i] != 0)
  31.                         j++;
  32.                 }  
  33.                 if(j == strlen(string) - 1){
  34.                     nr++;
  35.                     OK = 1;
  36.                 }  
  37.             }  
  38.             if(OK == 0)
  39.             {
  40.                 if(isdigit(string[0]) == 0 && string[1] == '\0')
  41.                         chars++;
  42.                 else words++;
  43.             }
  44.     }
  45.     printf("%d %d %d\n", words, chars, nr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement