Created
June 25, 2015 12:49
-
-
Save raryosu/9196f3e0ba63afbd534a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
char ch; | |
int alpha[26] = {0}, count; | |
// ファイルの末尾に到達するまでの間ループする | |
while((ch=getchar()) != EOF) { | |
if('a' <= ch && 'z' >= ch) { // 小文字の場合の処理 | |
alpha[ch-'a']++; | |
} else if('A' <= ch && 'Z' >= ch) { // 大文字の場合の処理 | |
alpha[ch-'A']++; | |
} | |
} | |
// 回答の出力 | |
for(count=0; count<26; count++) { | |
// a+0=a, a+1=b ... a+25=z | |
printf("%c : %d\n", 'a'+count, alpha[count]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment