20分代码,求助
查看原帖
20分代码,求助
1036599
Noah_Shen楼主2024/8/28 18:37
#include <bits/stdc++.h>
using namespace std;
int a[40001],cnt,temp;
int main(){
	char c;
	while(cin >> c){
	    a[++cnt] = c - '0';
	}
	int d = a[1];
	int n = sqrt(cnt);
	cout << n << " ";
	for(int i = 1; i <= cnt; i++){
	    if(a[i] == d){
	        temp++;
	    }else{
	        cout << temp << " ";
	        d = !d;
	        temp = 1;
	    }
        if(i == cnt){
            cout << temp;
        }
	}
	return 0;
}
2024/8/28 18:37
加载中...