求大佬帮忙看下

P1320 压缩技术(续集版)

Elitedj @ 2017-12-29 16:31:58

#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
string ch;
int main()
{
    int l,zero=0,one=0;
    string ch1;
    cin>>ch1;
    ch=ch1;
    l=ch1.length();
    for(int i=1;i<l;i++)
    {
        cin>>ch1;
        ch=ch+ch1;
    }
    cout<<l<<" ";
    for(int i=0;i<l*l;i++)
    {
        if(ch[i]=='0')
        {
            if(one>0)
            {
                cout<<one<<" ";
                one=0;
            }
            zero++;
        }
        else
        {
            if(zero>0)
            {
                cout<<zero<<" ";
                zero=0;
            }
            one++;
        }
    }
    if(zero!=0)  //输出最后一个数字
        cout<<zero;
    else
        cout<<one;
    return 0;
}

by neverwave @ 2018-08-10 15:04:30

太水了,这种题


by 据设错了 @ 2018-08-11 21:53:50

@neverwave 那你倒是回复人家的问题啊


|