1006. 换个格式输出整数 (15)
来源:互联网 发布:惠州乐知英语 编辑:程序博客网 时间:2024/05/16 15:17
让我们用字母B来表示“百”、字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。
输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。
输出格式:每个测试用例的输出占一行,用规定的格式输出n。
输入样例1:234输出样例1:
BBSSS1234输入样例2:
23输出样例2:
SS123
#include<stdio.h>#include<string.h>int main(){ char s[4]; char str[50]; int len,p=0,i,j,temp; scanf("%s",s); len=strlen(s); if(len==3){ temp=s[0]-'0'; for(i=0;i<temp;i++) str[p++]='B'; len=2; strcpy(s,s+1); } if(len==2){ temp=s[0]-'0'; for(i=0;i<temp;i++) str[p++]='S'; len=1; strcpy(s,s+1); } if(len==1){ temp=s[0]-'0'; for(i=0;i<temp;i++) str[p++]='1'+i; } str[p]='\0'; printf("%s\n",str);}
阅读全文
0 0
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 1006. 换个格式输出整数 (15)
- 一道关于扔球的DP问题
- linux线程2
- java中正则表达式以及Pattern和Matcher
- 神经网络笔记
- 利用Apache Bench进行网站服务器压力测试实例
- 1006. 换个格式输出整数 (15)
- 会计科目的共同类指的是什么
- android getevent用法
- java定时器时间配置
- angular2实战笔记--组件开发
- vs"链接器工具错误 LNK2026 XXX模块对于SAFESEH 映像是不安全的"
- 反射:类的加载机制
- Python爬取百度贴吧帖子
- [LeetCode] Remove Boxes