为什么0分

P1320 压缩技术(续集版)

zhdepe @ 2020-08-03 17:29:54

#include<bits/stdc++.h>
using namespace std;
char a[201],b[410];
int n,s=1;
int main()
{
    gets(a);
    strcat(b,a);
    n=strlen(a);
    for(int i=2;i<=n;i++)
    {
        gets(a);
        strcat(b,a);
    }
    cout<<n;
    if(b[0]=='1')
    {
        cout<<" 0";
    }
    for(int i=1;i<=strlen(b);i++)
    {

        if(b[i]==b[i-1])
        {
            s++;
        }
        else
        {
            cout<<" "<<s;
            s=1;
        }
    }
    return 0;
}

by zhdepe @ 2020-08-03 17:31:51

求大佬看看为什么0分


by andyli @ 2020-08-03 17:35:07

@zhdepe 慎用 gets,把 gets 换成 scanf


by K2sen @ 2020-08-03 18:14:46

因为WA了


by zhdepe @ 2020-08-05 15:19:14

谢谢大佬@andyli 不过为什么5个RE了


by zhdepe @ 2020-08-05 16:17:24

额数组开小了 已解决


|