酷代码 AI
菜单
服务商

C++实现统计整数出现最高频率的次数

```cpp #include <iostream> #include <cstring> #include <algorithm> int main() { int n; std::cin >> n; int count[101]; // 使用memset函数将count数组初始化为0 memset(count, 0, sizeof(count)); for (int i = 0; i < n; i++) { int num; std::cin >> num; // 统计每个数字出现的次数 count[num]++; } int maxCount = 0; for (int i = 0; i <= 100; i++) { // 使用max函数找出出现次数最多的数字的次数 maxCount = std::max(maxCount, count[i]); } std::cout << maxCount << std::endl; return 0; } ``` ######[AI问答 | 218点数解答 | 2026-05-17 20:18:25]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]