最讨厌这种样例过了还50分的……
查看原帖
最讨厌这种样例过了还50分的……
659323
link_yang楼主2024/5/27 15:11
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int cnt, a = 0;
    for(int i = 0; i <= s.size(); i++){
        if(s[i] != s[i + 1]){
            a++;
        }
    }
    for(int i = 0; i < (a - 1) * 2; i++){
        if(i == 0){
            cnt = 1;
        }
        else if(s[i] == s[i - 1]){
            cnt++;
        }
        else{
            cout<<cnt<<s[i - 1];
            cnt = 1;
        }
    }
    return 0;
}
2024/5/27 15:11
加载中...