Login
Immutable PageDiscussionInfoAttachments

Revision 10 as of 2012-05-09 01:05:25

Clear message
rei05/C言語

MMA

Help Me!

#include<stdio.h>

int main(){

int num,i,pri;
char ch,counter[26]={0};

while(scanf("%c",&ch)!=EOF){   //入力終了条件を\nからEOFに修正
  scanf("%c",&ch);
  if('a'<=ch&&ch<='z'){
    num=ch-'a';
    counter[num]++;
  }else if('A'<=ch&&ch<='Z'){
    num=ch-'A';
    counter[num]++;
  }
}

for(i=0;i<=25;i++){
  pri=counter[i];
  printf("%c : %d\n",i+'a',pri);
}

return(0);
}