程序代码:
int main() { int a[10] = {0}; int n; while (cin >> n) { ++a[n % 10]; } int value = 0; int count = 0; int b[10]; for (int i = 0; i < 10; ++i) { if (value < a[i]) { value = a[i]; count = 1; b[count - 1] = i; } else if (value == a[i]) { ++count; b[count - 1] = i; } } for (int i = 0; i < count; ++i) { cout << b[i] << " "; } cout << endl; return 0; }