1005: 贝贝的加密工作

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <sstream>
using namespace std;

string num2str(int i)
{
        stringstream ss;
        ss<<i;
        return ss.str();
}
bool isLower(char s)
{
        return (int)s >= (int)'a' && (int)s <= (int)'z';
}
int main(){
    string s;
    cin>>s;
    
    //bcaaaaaaaeeeeeeeeeeeaaaaaakkk   kkkA7bcE11f
    
    for(int i = 0 ; i< s.length(); i++)
    {
        int j = i+ 1;
        for(; j < s.length();j++)
        {
            if(s[i] != s[j] && isLower(s[i]))
                break;
        } 
        if(j - i > 1 && isLower(s[i])) 
        {
            string s1 = s.substr(j) + char((int)s[i] - 32) + num2str(j-i) + s.substr(0,i);
            cout<<s1<<endl; 
            s = s1;
            i = -1;
        }
    }
    cout<<s<<endl; 

//    cout<<setiosflags(ios::fixed)<<setprecision(4)<<s<<endl;
//    cout<< setiosflags(ios::fixed)<<setprecision(4) <<c<<endl; 
}

http://hmbb.hustoj.com/problem.php?id=1005

posted @ 2017-03-04 22:23  shiningrise  阅读(676)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css