洛谷P1603 斯诺登的密码
2024-08-31 21:53:20
https://www.luogu.org/problem/P1603
#include<bits/stdc++.h>
using namespace std;
struct s {
string n;
string t;
} pass[]= {
{"one",""},{"two",""},{"three",""},{"four",""},{"five",""},{"six",""},{"seven",""},{"eight",""},{"nine",""},
{"ten",""},{"eleven",""},{"twelve",""},{"thirteen",""},{"fourteen",""},{"fifteen",""},{"sixteen",""},{"seventeen",""},
{"eighteen",""},{"nineteen",""},{"twenty",""},{"a",""},{"both",""},{"another",""},{"first",""},{"second",""},{"third",""}
};
string searchs( string s) {
for(int i=; i<; i++) {
if(s==pass[i].n) {
return pass[i].t;//在列表中查找是否存在,不存在返回00
}
}
return "";
}
int main() {
bool output=false; //专为第三点设置
string str;
string x[];
for(int i=; i<; i++) {
cin>>str;
x[i]=searchs(str);
}
sort(x,x+);//利用string字典序的特性即可升序排序
bool flag=false;//判断从哪里要开始输出0,什么时候不要输出0
for(int i=; i<; i++) {
if(x[i]=="")
continue;
if(x[i][]==''&&flag==false) { //在最小数字判断第一位是否为0,如果是0,就直接输出第二位
flag=true; //标记 在以后遇到的数字都直接输出
} else cout<<x[i][];
cout<<x[i][];
output=true;
}
if(!output)cout<<"";//整个过程中都没有输出最后补一个0
}
最新文章
- 数据仓库之启用cdc
- iOS----关于第三方的运用(有待补充)
- 【HDU】4089 Activation
- NOIP(提高组)DAY1国王游戏
- 给eclipse配置sublime主题的背景
- linux 树型显示文件 tree ls tree 命令
- Python+ Selenium自动化登录腾讯QQ邮箱实例
- 迎战大数据-Oracle篇
- C# Redis 过期机制不生效问题
- C#获取应用程序路径
- Composer更新慢的解决方案
- Unity3D在移动平台下加载AssetBundle导致Shader效果不正确的问题
- SQL Server 磁盘请求超时的833错误原因分析以及解决
- CCNA实验3.单臂路由器
- Java调用Lua脚本(热载实现)
- nvm use 指定版本后无效 win7
- SHU 414 - 字符串进制转换
- (匹配)Antenna Placement --POJ --3020
- mongodb,redis,mysql的区别和具体应用场景
- Windows隐藏账户