PTA 1006- change the output format to write the integer c and python

topic

Let B be represented by the letter "hundred", the letter S represents a positive integer "ten", denoted by 12 ... n is not zero digit n (<10), any change to the output format of a no more than three . 234 should be output as e.g. BBSSS1234, because it has two "hundred", 3 "ten", and 4 bits.

Input formats:

Each test comprises a test input, given a positive integer n (<1000).

Output formats:

Each output test case per line, with n predetermined output format.

Sample Input 1:

234

Output Sample 1:

BBSSS1234

Sample Input 2:

23

Output Sample 2:

SS123

C language

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    scanf("%d",&i);
    for(int j=0;j<(i/100);j++)
        printf("B");
    for(int j=0;j<(i%100/10);j++)
        printf("S");
    for(int j=0;j<(i%10);j++)
        printf("%d",j+1);
    return 0;
}

Write python

i = input()
for j in range(int(i)//100):
    print('B',end='')
for j in range((int(i)%100)//10):
    print('S',end='')
for j in range(int(i)%10):
    print(j+1,end='')

Guess you like

Origin blog.csdn.net/qq_32188669/article/details/93123865