让我们用字母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<stdio.h>
int main()
{
int n;
int k = 0;
char str1[10], str2[10], str3[10];
scanf("%d", &n);
while (n != 0)
{
int j;
if (k == 0)
{
for (j = 0; j < n % 10; j++)
{
str3[j] = (j + 1 + '0');
}
str3[j] = '\0';
}
if (k == 1)
{
for (j = 0; j < n % 10; j++)
{
str2[j] = 'S';
}
str2[j] = '\0';
}
if (k == 2)
{
for (j = 0; j < n % 10; j++)
{
str1[j] = 'B';
}
str1[j] = '\0';
}
n /= 10;
k++;
}
if (k == 1)
{
printf("%s", str3);
}
if (k == 2)
{
printf("%s%s", str2, str3);
}
if (k == 3)
{
printf("%s%s%s", str1, str2, str3);
}
return 0;
}