PAT Basic Level 1006

Posted Ponytai1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT Basic Level 1006相关的知识,希望对你有一定的参考价值。

AC代码

 1 #include <stdio.h>
 2 int main ()
 3 {
 4     int x;
 5     scanf("%d",&x);
 6     int mask = 1;
 7     int temp = x;
 8     while(temp != 0 )
 9     {
10         temp = temp/10;
11         mask = mask * 10; 
12     }
13     mask = mask/10;
14     while (mask > 0)
15     {
16         if(mask == 100)
17         {
18             temp = x/mask;
19             while(temp > 0)
20             {
21                 printf("B");
22                 temp--;
23             }
24             x = x%mask;
25             mask = mask/10;
26         }else
27         if(mask == 10)
28         {
29             temp = x/mask;
30             while(temp > 0)
31             {
32                 printf("S");
33                 temp--;
34             }
35             x = x % mask;
36             mask = mask/10;
37         }else
38         if(mask == 1)
39         {
40             temp = x/mask;
41             int i = 1;
42             while(temp>0)
43             {
44             
45                 printf("%d",i);
46                 i++;
47                 temp--;    
48             }
49             x = x % mask;
50             mask = mask/10;
51         }
52         
53     }
54     return 0 ;
55 }

 

以上是关于PAT Basic Level 1006的主要内容,如果未能解决你的问题,请参考以下文章

PAT(Basic Level) 1006

(Python) PAT(Basic Level) Practice 刷题笔记

(Python) PAT(Basic Level) Practice 刷题笔记(1-33)

PAT (Basic Level) Practise 1040 有几个PAT(DP)

PAT Basic Level 1033

PAT Basic Level 1009