20分,球大佬!

P1320 压缩技术(续集版)

baibaobao666 @ 2023-03-21 18:38:41

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string a,all;
    int len,c0=1,c1=1;//len输出长度,c0c1设为1这样到时候不用加
    cin >> a;
    len = a.size();
    all += a;
    for(int i = 1;i <= len-1;i++)
    {
        cin >> a;
        all += a;
    }
    bool type;
    if(all[0] == '0')
    type=0;
    else
    type=1;
    cout << len << " ";
    for(int i = 1;i < len*len;i++)
    {
        if(type == 0 && all[i] == '1')
        {
            cout << c0 << " ";
            c0 = 1;
            type = 1;
        }
        else if(type == 1 && all[i] == '0')
        {
            cout << c1 << " ";
            c1 = 1;
            type = 0;
        }
        else if(all[i] == '0')
        c0++;
        else if(all[i] == '1')
        c1++;//判断
    }
    if(all[len*len-1] == '1')//再次输出答案,一免最后一个没输出
    {
        cout << c1 << " ";
        c0 = 1;
        type = 1;
    }
    else if(all[len*len-1] == '0')
    {
        cout << c0 << " ";
        c1 = 1;
        type = 0;
    }

    return 0;
}

不会呀qwq


by Max6700 @ 2023-05-03 12:01:13

@baibaobao666 e


by Max6700 @ 2023-05-03 12:02:32

还要么?


by Max6700 @ 2023-05-03 12:05:38

#include<bits/stdc++.h>
using namespace std;

int n;
char c;

int a[10000];
int i=0;

int last,now;
int cnt=0;

int j=0;

int main(){

    while(cin>>c)
    {
       now=int(c-'0');
       if(__!=__)
       {
           a[j]=__;
           j++;
           cnt=__;//1?0?

       }
       else
       {
           cnt++;
       }
       last=now;
       i++;
    }

    a[j]=__;
    j++;

    cout<<__(i)<<" ";//好像要用什么函数开方……
    for(int k=__;k__j;k++)//0?1?<=?<?
    {
        cout<<a[__]<<" ";
    }

    return 0;
}

by Max6700 @ 2023-05-03 12:06:02

填空食用


by baibaobao666 @ 2023-05-05 19:29:11

@Max6700 又是你?谢谢谢谢


by Max6700 @ 2023-05-05 19:49:42

@baibaobao666 我很好奇,我要做的题,你咋都做过啊……


by baibaobao666 @ 2023-05-07 11:36:54

@Max6700 呃,我也不知道,两只塔姆沃斯牛 The Tamworth Two你做过了吗?刚刚AC


by Max6700 @ 2023-05-07 12:16:07

@baibaobao666 (没)我荔枝要刷完题单里的所有题


|