Login
Immutable PageDiscussionInfoAttachments

Revision 17 as of 2012-05-15 17:19:20

Clear message
rei05/C言語

MMA

C言語

AOJ解答

Help Me!

解決済み

#include<stdio.h>

int main(){

int num,i,pri;
char ch,counter[26]={0};         //counterはintでいいんですね

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);
}