入门模拟——(字符串处理)B1006.换个格式输出整数

 

 

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
const int MAX_LEN = 100005;
//const int MAX_D = 31;
int main(){
    int n;
    cin>>n;
    int Bdigit = n / 100;
    int Sdigit = (n / 10)%10;
    int Ddigit = n % 10;
    if(Bdigit != 0){
        for(int i=0;i<Bdigit;++i){
            cout<<'B';
        }
    } 
    if(Sdigit != 0){
        for(int i = 0;i<Sdigit;++i){
            cout<<'S';
        }
    }
    if(Ddigit != 0){
        for(int i=1;i<=Ddigit;++i){
            if(i<=Ddigit){
                cout<<i;
            }
        }
    }
    system("pause");
    return 0;
} 
posted @ 2020-01-01 19:21  JasonPeng1  阅读(120)  评论(0编辑  收藏  举报