RenHao

e-Tutor_7

Sep 24th, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define MAX_CHAR_SIZE 1000
  5. int convert(char c){
  6.     return (c<91)?c-'A':c-'a';
  7. }
  8. int main(int argc, const char * argv[])
  9. {
  10.     int n = 0, Num_of_alphabet[26];
  11.     int i = 0;
  12.     char Sentence[MAX_CHAR_SIZE];
  13.     for(; i<26; i++)
  14.         Num_of_alphabet[i] = 0;
  15.    
  16.     scanf("%d",&n);
  17.     int c=0;
  18.     while(c<=n)
  19.     {
  20.         gets(Sentence);
  21.         i=0;
  22.         while(Sentence[i]!='\0')
  23.             Num_of_alphabet[convert(Sentence[i++])]++;
  24.         c++;
  25.     }
  26.    
  27.     for(i=0; i<26; i++)
  28.         printf("%c %d\n",i+'A',Num_of_alphabet[i]);
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment