CODEFORCES 535A 解题报告
来源:互联网 发布:三界淘宝商 编辑:程序博客网 时间:2024/04/28 01:39
CODEFORCES 535A 解题报告
本题仍为水题,只要按照英语中的数字命名法来就可以了,STL简化一下操作,把基本元素枚举出来就可以了。map1~10,20,30,…,90。映射为单词。之后拆分十位和个位,用连字符拼接即可。
以下是代码(可直接AC):
#include <iostream>#include <string>#include <map>using std::cin;using std::cout;using std::map;using std::string;int main(){ int s; map<int,string> word; //直接枚举 word[0]="zero"; word[1]="one"; word[2]="two"; word[3]="three"; word[4]="four"; word[5]="five"; word[6]="six"; word[7]="seven"; word[8]="eight"; word[9]="nine"; word[10]="ten"; word[11]="eleven"; word[12]="twelve"; word[13]="thirteen"; word[14]="fourteen"; word[15]="fifteen"; word[16]="sixteen"; word[17]="seventeen"; word[18]="eighteen"; word[19]="nineteen"; word[20]="twenty"; word[30]="thirty"; word[40]="forty"; word[50]="fifty"; word[60]="sixty"; word[70]="seventy"; word[80]="eighty"; word[90]="ninety"; cin>>s; if(s>=0&&s<=19||s%10==0)//0~9不拆,整十不拆 cout<<word[s]; else cout<<word[s-s%10]<<'-'<<word[s%10];//拆分输出 return 0;}
0 0
- CODEFORCES 535A 解题报告
- 解题报告 codeforces 242A
- codeforces 1A 解题报告
- CODEFORCES 534A 解题报告
- CodeForces 240A A. Cinema 解题报告
- codeforces Round #237(div2) A解题报告
- codeforces Round #238(div2) A解题报告
- codeforces Round #241(div2) A解题报告
- codeforces Round #269(div2) A解题报告
- codeforces Round #267(div2) A解题报告
- codeforces Round #271(div2) A解题报告
- codeforces Round #272(div2) A解题报告
- codeforces Round #264(div2) A解题报告
- codeforces Round #263(div2) A解题报告
- codeforces Round #273(div2) A解题报告
- codeforces Round #274(div2) A解题报告
- codeforces Round #261(div2) A解题报告
- codeforces Round #260(div2) A解题报告
- 习题10-12 汉堡 UVa557
- 无休止的手工测试,不累吗?
- 说说Android通知那些事儿
- switch string
- 一个白盒测试菜鸟的心路历程
- CODEFORCES 535A 解题报告
- 设计一套自己的自动化体系
- MFC对话框最小化到托盘
- 编写单元测试的10个Reason
- Java Post测试代码(https)
- 回归测试知多少
- 浅谈软件测试工程师的两个意识,六个心
- 搜狗输入法,好用不?原理是什么?
- 为什么要搭建自动化测试框架