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

MMA
Differences between revisions 7 and 8
Revision 7 as of 2012-05-08 22:09:37
Size: 579
Editor: alstamber
Comment:
Revision 8 as of 2012-05-09 01:00:33
Size: 910
Editor: rei05
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
 * AOJ10020番WrongAnswer  * AOJ10020番 Wrong Answer
  * [[http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10020]]
Line 15: Line 16:
    if(ch=='\n') break;     if(scanf("%c",&ch)==EOF) break; //入力終了条件を\nからEOFに修正
Line 35: Line 36:
 * すみません具体的にどこをどう直せば良いですか?問題文を見る限り動かすのは1回でいいと思うのですが。-- [[rei05]] <<DateTime(2012-05-09T01:00:33+0900)>>

Help Me!

#include<stdio.h>

int main(){

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

while(1){
  scanf("%c",&ch);
    if(scanf("%c",&ch)==EOF) break; //入力終了条件を\nからEOFに修正
  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

  • すみません具体的にどこをどう直せば良いですか?問題文を見る限り動かすのは1回でいいと思うのですが。-- rei05 2012-05-09 01:00:33

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