1006. 换个格式输出整数
来源:互联网 发布:网络言论自由的特点 编辑:程序博客网 时间:2024/05/22 01:00
让我们用字母B来表示“百”、字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。
输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。
输出格式:每个测试用例的输出占一行,用规定的格式输出n。
输入样例1:
234输出样例1:
BBSSS1234思路:按照数的逆序打印为思路将其先存起来,最后依次打印:
int main(){int n = 0;scanf("%d",&n);int count = 0;int arr[4] = {0};while (n){arr[count] = n%10;n = n/10;count++;}int i;for(i=0;i<arr[2];i++) printf("B");for(i=0;i<arr[1];i++) printf("S"); for(i=0;i<arr[0];i++) printf("%i",i+1);return 0;}
阅读全文
0 0
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- PAT 1006. 换个格式输出整数
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数
- 1006. 换个格式输出整数 (15)
- PAT 1006. 换个格式输出整数
- pat 1006. 换个格式输出整数
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- MySQL索引的创建、删除 index creat/delete
- IOS获取相册照片的大小
- Java关键字
- java概述与开发环境
- 回归爬虫,拥抱scrapy&splash。抓facebook public post like、comment、share
- 1006. 换个格式输出整数
- kaminari ajax
- 图片在浏览器局部拖放
- Jquery 对除了自身,其他同胞对象
- iptables
- js的String
- Logistic regression为什么不用Square error做loss function?
- Virtualenv虚拟环境安装
- poj 1753 Flip Game(dfs)