编程题目:PAT 1006. 换个格式输出整数 (15)

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

/*
http://pat.zju.edu.cn/contests/pat-b-practise/1006
*/
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int num;
	string str="";
	cin>>num;
	int temp;
	temp= num/100;
	for(int i=0;i<temp;i++)
		str +="B";
	num=num-temp*100;
	temp = num/10;
	for(int i=0;i<temp;i++)
		str +="S";
	num = num-temp*10;
	num %=10;
	for(int i=1;i<=num;i++)
		str+=i+48;
	cout<<str<<endl;
	system("pause");
	return 0;
}




posted @ 2014-07-04 20:35  F8Master  阅读(238)  评论(0编辑  收藏  举报