码迷,mamicode.com
首页 > 其他好文 > 详细

PAT 乙级 1006

时间:2018-07-12 19:55:10      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:ros   span   bsp   div   cout   ios   乙级   c++   std   

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main() {
 5     int n = 0;
 6     cin >> n;
 7     int chu = n, yu = 0;
 8     int num[3], loc = 0;
 9     while (chu >= 10) {
10         yu = chu % 10;
11         chu /= 10;
12         num[loc] = yu;
13         loc++;
14     }
15     num[loc] = chu;
16     for (int i = loc; i >= 0; i--) {
17         if (i == 2)
18             for (int j = 0; j < num[i]; j++)
19                 cout << B;
20         else if (i == 1)
21             for (int j = 0; j < num[i]; j++)
22                 cout << S;
23         else
24             for (int j = 0; j < num[i]; j++)
25                 cout << j + 1;
26     }
27     cout << endl;
28 
29     return 0;
30 }

 

PAT 乙级 1006

标签:ros   span   bsp   div   cout   ios   乙级   c++   std   

原文地址:https://www.cnblogs.com/moujun1001/p/9300776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!