1006. 换个格式输出整数

 1 /*
 2  * Main.c
 3  * 1006. 换个格式输出整数
 4  *  Created on: 2014年8月28日
 5  *      Author: Boomkeeper
 6  ***********测试通过*********
 7  */
 8 
 9 #include <stdio.h>
10 
11 int main(void){
12 
13     int temp[4]={0,0,0,0};//存放整数的各位数
14     int in;
15     int i,j;
16 
17     scanf("%3d",&in);
18 
19     j=0;
20     while(in!=0){
21         temp[j]=in%10;
22         j++;
23         in/=10;
24     }
25 
26     for(i=0;i<temp[2];i++)
27         printf("B");
28     for(i=0;i<temp[1];i++)
29         printf("S");
30     for(i=0;i<temp[0];i++)
31         printf("%i",i+1);
32     printf("
");
33 
34     return 0;
35 }

题目链接:

http://pat.zju.edu.cn/contests/pat-b-practise/1006

原文地址:https://www.cnblogs.com/boomkeeper/p/1006b.html