Login
Immutable PageDiscussionInfoAttachments
Diff for "rei05/C言語"

MMA
Differences between revisions 6 and 7
Revision 6 as of 2012-05-08 17:47:04
Size: 430
Editor: rei05
Comment:
Revision 7 as of 2012-05-08 22:09:37
Size: 579
Editor: alstamber
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Help Me = = Help Me! =
Line 33: Line 33:

 * counterをリセットしないと2回目以降の結果がバグると思いますよん-- [[alstamber]] <<DateTime(2012-05-08T22:09:37+0900)>>

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);
}
  • counterをリセットしないと2回目以降の結果がバグると思いますよん-- alstamber 2012-05-08 22:09:37

rei05/C言語 (last edited 2012-07-16 17:50:37 by nomeaning)