标签:
1 #include <iostream> 2 #include <stdio.h> 3 #include <cmath> 4 #include <string> 5 #include <algorithm> 6 #include <memory.h> 7 8 using namespace std; 9 10 const double PI = acos(-1.0); 11 const double eps = 1e-6; 12 const double INF = 1e9 + 7; 13 14 15 16 int a[10]; 17 18 19 int main() 20 { 21 freopen("data.in", "r", stdin); 22 23 24 memset(a, 0, 10); 25 string str; 26 int maxNum = 0; 27 28 cin >> str; 29 30 31 for (int i = 0; i < str.size(); i++) 32 { 33 a[str[i] - ‘0‘]++; 34 if (a[str[i] - ‘0‘]>maxNum) 35 { 36 maxNum = a[str[i] - ‘0‘]; 37 } 38 } 39 for (int i = 0; i < 10; i++) 40 { 41 if (a[i] == maxNum) 42 { 43 cout << i<<","<<maxNum<< endl; 44 break; 45 46 } 47 48 } 49 50 51 system("pause"); 52 return 0; 53 }
标签:
原文地址:http://www.cnblogs.com/lishichao/p/4847210.html