1006

来源:互联网 发布:pcb设计软件 编辑:程序博客网 时间:2024/06/16 14:18
/*让我们用字母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 <cstdio>#include <cstring>#include <algorithm>#include <stack>#define MAX 100005using namespace std;int main() { int n; scanf("%d", &n); int b = 0, s = 0, g = 0; b = n / 100; s = n / 10 % 10; g = n % 10; while(b--) { printf("B"); } while(s--) { printf("S"); } int i; for(i = 1; i <= g; i++) { printf("%d", i); }return 0;}

0 0
原创粉丝点击