1006 change the format of the output integer (15 minutes)
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 format:
Each test input comprises a test gives a positive integer n (<1000).
Output format:
Each test row for output, n output with a predetermined format.
Sample Input 1:
234
Output Sample 1:
BBSSS1234
Input Sample 2:
23
Output Sample 2:
SS123
analysis
Can be directly printed separately
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
for (int i=0; i<n/100; i++) {
cout << "B";
}
n%=100;
for (int i=0;i< n/10; i++) {
cout << "S";
}
for (int i=0; i<n%10; i++) {
cout << i+1;
}
return 0;
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int a =m/100;
for (int i=0;i<a;i++){
System.out.print("B");
}
int b = (m-a*100)/10;
for (int i=0;i<b;i++){
System.out.print("S");
}
int c = m%10;
for (int i=1;i<=c;i++){
System.out.print(i);
}
}
}