问问大佬我为什么过不了

P1320 压缩技术(续集版)

qianlanse @ 2019-09-29 20:49:32

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char a[40001];
    char b[201];
    cin >> a;
    long n = strlen(a);
    for(int i = 2; i <= n; i++)
    {
        cin >> b;
        strcat(a, b);
    }
    cout << n << " ";
    char k = a[0];
    int temp = 0;
    for(int i = 0; i < strlen(a); i++)
    {
        if(a[i] == k)
        {
            temp++;
        }
        else
        {
            cout << temp << " ";
            temp = 1;
            k = a[i];
        }
    }
    cout << temp;
    return 0;
}

|