Yosuga_sora @ 2023-11-20 20:09:43
#include <stdio.h>
#include <math.h>
int main(){
char a[10000];
int m=0;
while((scanf("%c",&a[m]))!=-1){
if(a[m]=='\n'){
continue;
}
m++;
}
int n,b[10000];
n=sqrt(m);
for(int i=0;i<m;i++){
a[i]=a[i]-'0';
}
int number=0,counter=0;
if(a[0]!=0){
b[0]=0;
number=1,counter=0;
for(int i=0;i<m;){
if(number%2!=0){
while(a[i]==1){
counter++;
i++;
}
b[number]=counter;
counter=0;
}
if(number%2==0){
while(a[i]==0){
counter++;
i++;
}
b[number]=counter;
counter=0;
}
number++;
}
}
if(a[0]==0){
for(int i=0;i<m;){
if(number%2!=0){
while(a[i]==1){
counter++;
i++;
}
b[number]=counter;
counter=0;
}
if(number%2==0){
while(a[i]==0){
counter++;
i++;
}
b[number]=counter;
counter=0;
}
number++;
}
}
printf("%d ",n);
for(int i=0;i<number;i++){
printf("%d ",b[i]);
}
return 0;
}
by aqzz1222 @ 2023-11-26 15:48:46
判断是否换行的部分再加一个'\r'的判断 '\n'是换行 '\r'是回车