Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.    char s[200];
  7.    int c = 0, szam1[26] = {0}, x = 0, space = 0;
  8.    int b = 0, szam2[26] = {0}, y = 0, pont = 0;
  9.  
  10.    printf("Adja meg a kivant szoveget: \n");
  11.    gets(s);
  12.  
  13.    while (s[c] != '\0') {
  14.  
  15.       if (s[c] >= 'a' && s[c] <= 'z') {
  16.          x = s[c] - 'a';
  17.          szam1[x]++;
  18.       }
  19.  
  20.     c++;
  21.    
  22.    if (s[b] >= 'A' && s[b] <= 'Z'){
  23.         y = s[b] - 'A';
  24.         szam2[y]++;
  25.         }
  26.     b++;
  27.    
  28.     //  space  és  pont.
  29.     if (s[b] == '.'){
  30.         pont++;
  31.     }
  32.         b++;
  33.        
  34.        
  35.  
  36.     if (s[c] == ' '){
  37.         space++;
  38.         c++;
  39.     }
  40.  
  41.        
  42.    }
  43.  
  44.  
  45.  
  46.     for (c = 0; c < 26; c++)
  47.          printf("%c : %d db\n", c + 'a', szam1[c]);
  48.  
  49.    for (b = 0; b < 26; b++)
  50.         printf("%c : %d db\n", b + 'A', szam2[b]);
  51.  
  52.     printf(". : %d db\n", pont);
  53.     printf("  : %d db\n", space);
  54.  
  55.    return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement