10020 - Counting Characters
#include <cctype> #include <cstdio> #include <iostream> #include <string> using namespace std; void Slove(void) { int count[26]={0}; string str; while ( getline(cin,str) ) for (int i=0; i<str.length(); ++i) { if ( isupper(str[i]) ) str[i]=tolower(str[i]); if ( islower(str[i]) ) ++count[str[i]-'a']; } for (int i=0; i<26; ++i) printf ("%c : %d\n", 'a'+i, count[i]); } int main(void) { Slove(); return 0; }
複数行じゃなく1行だと思っていたのでWrongAnswer食らってました。。