标签:
dev-cpp需要自己对数组零初始化
#include <iostream> #include <cstring> using namespace std; int main() { int n; cin >> n; cin.get(); int a[30]; char c[1020]; while(n--) { int Max = 0, x = 0; memset(a,0,sizeof(a)); cin >> c; for(int i = 0; i < strlen(c); i++) a[c[i]-‘a‘]++; for(int i= 0; i < 26; i++) if(a[i] > Max) { Max = a[i]; x = i; } cout << char(‘a‘+x) << endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/ekinzhang/p/4374395.html