题目地址:http://pat.zju.edu.cn/contests/pat-b-practise/1006
1 #include<stdio.h> 2 3 int main() 4 { 5 int n; 6 int g, s, b, i; 7 g = s = b = 0; 8 scanf( "%d", &n ); 9 g = n % 10; 10 n = n / 10; 11 if( n != 0 ) 12 { 13 s = n % 10; 14 n = n / 10; 15 } 16 if( n != 0 ) 17 { 18 b = n % 10; 19 } 20 if( b!= 0 ) 21 { 22 for( i = 0; i < b; ++i ) 23 { 24 printf("B"); 25 } 26 } 27 if( s!= 0 ) 28 { 29 for( i = 0; i < s; ++i ) 30 { 31 printf("S"); 32 } 33 } 34 if( g != 0 ) 35 { 36 for( i = 0; i < g; ++i ) 37 { 38 printf("%d", i + 1); 39 } 40 } 41 printf("\n"); 42 return 0; 43 }