computor @ 2024-08-30 19:43:37
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x=0,j;
char c[10000];
scanf("%s",&c);
n=strlen(c);
for(int i=1;i<=n-1;i++)
{
scanf("%s",&c[i*n]);
}
j=0;
printf("%d ",n);
while(x++<n*n)
{
j++;
if(c[x]!=c[x-1])
{
printf("%d ",j);
j=0;
}
}
}
by eatkeyboard @ 2024-08-30 20:07:13
第一个数表示连续有几个0,你这段代码如果开头是1的话就直接输出有几个连续的1了,要加特判
by eatkeyboard @ 2024-08-30 20:14:02
只要在while之前多加一句if(c[0]!='0')printf("0 ");就好了
by computor @ 2024-08-30 20:53:50
@eatkeyboard 好的谢谢大佬