求助,显示运行错误
查看原帖
求助,显示运行错误
1051378
hsy0824楼主2024/8/1 02:41
#include <bits/stdc++.h>
using namespace std;
int main(){
    /*tmp是a数组下标计数器,cnt = 当前数字出现次数*/
    int sum = 0,a[50000],tmp = 0,cnt = 1;
    bool cut = 0;
    int x;
    while (1){
        cin >> x;
        if (x == '\0') break;
        sum++;
        if (x == cut){
            cnt++;
            continue;
        }
        a[tmp] = cnt;
        tmp++;
        cnt = 1;
        cut = !cut;
    }
    cout << sqrt(sum) << ' ';
    for (int i = 0; i <= tmp-1; i++){
        cout << a[i] << ' ';
    }
    return 0;
}
2024/8/1 02:41
加载中...