求助。WA //△\\

P1320 压缩技术(续集版)

Jacky_g @ 2019-02-15 19:57:20

#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,num='0',ans=0;
    string t,s;
    cin>>t;
    s+=t;
    for(i=2;i<=t.size();i++){
        getline(cin,t);
        s+=t;
    }
    cout<<s<<endl;
    cout<<t.size()<<" ";
    for(i=0;i<s.size();i++){
        if(num==s[i])
            ans++;
        else{
            num=s[i];
            cout<<ans<<" ";
            ans=1;
        }
    }  
    return 0;
}
//0001000
//0001000
//0001111
//0001000
//0001000
//0001000
//1111111

|