题解 | #字符串编码#

字符串编码

http://www.nowcoder.com/practice/56a487c342a64d2ea4c3a0b0144b42d0

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

int main(void) {
    string str;
    cin >> str;
    
    int i = 0;
    for(;i < str.size();) {
        int count = 1;
        int j = i + 1;
        while(j<str.size() && str[i] == str[j]) {
            j++;
            count++;
        }
        cout << count << str[i];
        i = j;
    }
    
    return 0;
}

拼多多笔试题考过

全部评论

相关推荐

菜菜狗🐶:双非之光
找工作,你会甘心进小厂还...
点赞 评论 收藏
分享
12-23 18:51
中南大学 Java
唉又萌混过关:是不是那种收钱盖实习章的机构?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务