Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 26th, 2012  |  syntax: C  |  size: 0.56 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int isLetters(char *alpha, int *frequency);
  5.  
  6. int main(void){
  7.   char alpha[26];
  8.   int frequency[26];
  9.   char x;
  10.  
  11.   setOperation(alpha, frequency);
  12.   while(x =! EOF){
  13.         x = getchar();
  14.        
  15.         if( 'a' <= x && x <= 'z'){
  16.                 frequency[x-'a']++;
  17.         }
  18. }
  19.         int l;
  20.   for(l=0; l<26; l++){
  21.         printf("%s, %d \n", alpha[l], frequency[l]);
  22. }
  23.   return 0;
  24. }
  25.  
  26. int setOperation(char *alpha, int *frequency){
  27.   int i, b;
  28.   int a = 26;
  29.  
  30.   for(b=0; b < a; b++){
  31.       alpha[b] = b + 'a';
  32.           frequency[b]=0;
  33.     }
  34.        
  35.   return 0;
  36. }