换个格式输出整数 (15)

    xiaoxiao2021-03-25  96

    B1006. 换个格式输出整数 (15)

    Description:

    让我们用字母B来表示“百”、字母S表示“十“,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。

    Input:

    每个测试输入包含1个测试用例,给出正整数n(<1000)。

    Output:

    每个测试用例的输出占一行,用规定的格式输出n。

    Sample Input1:

    234

    Sample Output1:

    BBSSS1234

    Sample Input2:

    23

    Sample Output2:

    SS123

    #include<stdio.h> #include<stdlib.h> int main() { int num,i,j,k; scanf("%d",&num); i=num/100; if(i>0){ for(j=0;j<i;j++) printf("B"); } i=num/10; if(i>0) { for(j=0;j<i;j++) printf("S"); } i=num; if(i>0){ for(j=1;j<=i;j++) printf("%d",j); } system("pause"); return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-25908.html

    最新回复(0)