标签:
输入字符串,并比较输入频率最大的那个字符串
#include<iostream> using namespace std; int main( ) { int round; cin >> round; while (round) { char ballo[1001][16]; int fre[1001] = { 0}; char tem[15]; int m = 0, n = 0; int count = 0; for (int i = 0; i < round; i++) { cin >> tem; int j = 0; while (j != i && strcmp(tem,ballo[j])) { j++; } if (!strcmp(tem,ballo[j])) fre[j]++; else { strcpy_s(ballo[j], tem); fre[j]++; count++; } } int max = fre[0]; int pos = 0; for (int u = 0; u < count; u++) { if (fre[u]>max) { max = fre[u]; pos = u; } } cout << ballo[pos]<<endl; cin >> round; } return 0; } |
|||
|
啊啊啊啊啊啊啊啊啊啊啊真是刷了一道有意义的题哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 杭电1004
标签:
原文地址:http://www.cnblogs.com/chendashennihao/p/5361172.html