zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    练习题
    练习
    2.15
    数组
    java聊天工具12.4
    11.13(2)
    11.13
    10.30 作业
    10.23
    面向对象
  • 原文地址:https://www.cnblogs.com/shiningrise/p/6502966.html
Copyright © 2011-2022 走看看