C++ 统计连续相等整数个数 - 代码示例与解析 日期: 2027-09-13 标签: 常规 #include using namespace std; int n, a[100], cnt; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { cnt = 1; for (int j = i+1; j <= n; j++) { if (a[j] == a[i]) { cnt++; } else { break; } } cout << cnt << " "; } return 0; } 原文地址: https://www.cveoy.top/t/topic/qc6P 著作权归作者所有。请勿转载和采集! 免费AI点我,无需注册和登录