PTA 乙级 1006 换个格式输出整数 (15分) C/C++

 

 C/C++

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main() {
 5     int n = 0;
 6     cin >> n;
 7     int b = n / 100;
 8     int s = n / 10 % 10;
 9     int g = n % 10;
10     if (b != 0) { for (int i = 0; i < b; i++)cout << "B"; }
11     if (s != 0) { for (int i = 0; i < s; i++)cout << "S"; }
12     if (g != 0) { for (int i = 0; i < g; i++)cout << i+1; }
13     return 0;
14 }

没看清题,没想到这么简单,以为n位数很多

 

posted @ 2020-06-25 03:38  上帝的绵羊  阅读(164)  评论(0编辑  收藏  举报