求助

P1320 压缩技术(续集版)

wangyuannet @ 2024-08-25 17:31:17

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
    int n,b=0;
    char a[205],d[205];
    cin>>a;
    n=strlen(a);
    for(int i=1;i<n;i++){
    cin>>d;
    strcat(a,d);
    }
    cout<<n<<" ";
    if(a[0]=='0'){
    for(int i=1;i<n*n;i++){
    if(a[i]==a[i-1])b++;
    else {
    cout<<b+1<<" ";b=0;} 
}
}
    if(a[0]=='1'){
    cout<<0<<" ";
    for(int i=1;i<n*n;i++){
    if(a[i]==a[i-1])b++;
    else {
    cout<<b+1<<" ";b=0;} 
}
    }
cout<<b+1;
return 0;
}

是哪里理解有问题吗?只有40分


|