Skip to content

Instantly share code, notes, and snippets.

@raryosu
Created June 25, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raryosu/9196f3e0ba63afbd534a to your computer and use it in GitHub Desktop.
Save raryosu/9196f3e0ba63afbd534a to your computer and use it in GitHub Desktop.
#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