U214999 数字编码不会!求解!!!

题目总版

mao13588607991 @ 2024-11-02 08:54:50


by JiangHaoXuan15 @ 2024-11-02 09:32:14

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

int main()
{
    char t='a';
    string s;
    cin >> s;
    s+="a";
    for(int i=0, j=0;i<s.size();i++, j++)
    {
        if(t=='a')
        {
            t=s[i];
        }
        else
        {
            t=s[i-1];
        }
        if(s[i]!=t)
        {
            cout << j << t;
            j=0;
        }
    }
    return 0;
}

|