Let us use the letter B to denote "hundred", the letter S for "Ten", "12...N" to represent the single digit n (<10), in a different format to output any of the 3-bit positive integer. For example, 234 should be output as BBSSS1234, because it has 2 "hundred", 3 "ten", and a single digit of 4.
input Format: each test input contains 1 test cases, giving a positive integer n (<1000).
Output format: one row for each test case output n in the specified format.
Input Sample 1:
234
Output Example 1:
BBSSS1234
Input Sample 2:
23
Output Example 2:
SS123
Accept integers with strings, eliminating the number of digits to judge integers
#include <stdio.h>#include<string.h>intMain () {Chara[Ten]; scanf ("%s", a); intn =strlen (a); if(n==3){ for(intI=0; i<a[0]-'0'; i++) {printf ("B"); } for(intI=0; i<a[1]-'0'; i++) {printf ("S");; } for(intI=1; i<=a[2]-'0'; i++) {printf ("%d", i); } } if(n==2){ for(intI=0; i<a[0]-'0'; i++) {printf ("S");; } for(intI=1; i<=a[1]-'0'; i++) {printf ("%d", i); } } if(n==1){ for(intI=1; i<=a[0]-'0'; i++) {printf ("%d", i); } } }
PAT 1006. Output integers in a different format (15)