1006. 换个格式输出整数 (15)
时间限制
400 ms
内存限制
32000 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
让我们用字母B来表示“百”、字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。
输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。
输出格式:每个测试用例的输出占一行,用规定的格式输出n。
输入样例1:234输出样例1:
BBSSS1234输入样例2:
23输出样例2:
SS123
#include<iostream>
#include<string>
using namespace std;
int main(){
string str;
cin>>str;
int count,j,k,m;
count=str.size();
for(int i=0;i<count;i++){
if(i==count-1){ //个位数的时候
j=str[count-1]-'0';
int ss=1;
while(j>0){
cout<<ss;
j--;
ss++;
}
}else if(i==count-2){ //十位数的时候
k=str[count-2]-'0';
while(k>0){
cout<<"S";
k--;
}
}else{
m=str[count-3]-'0';
while(m>0){
cout<<"B";
m--;
}
}
}
//队列的用法 或者字母的用法
//for_each(vec.begin()+1,vec.end(),printf);
cin>>str;
return 0;
}