Login
Immutable PageDiscussionInfoAttachments

Revision 4 as of 2012-05-08 17:46:20

Clear message
rei05/C言語

MMA

=Help Me!=

#include<stdio.h>

int main(){

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

while(1){
  scanf("%c",&ch);
    if(ch=='\n') break;
  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);
}