洛谷P1603 斯诺登的密码

当需要字符串对应数字时,map是非常好用的 

#include <bits/stdc++.h>
using namespace std;

map<string,int>q;

string s; 

int st[1000],cnt=0;

int main()
{
	/*
		打表
		当需要字符串对应数字时,map是非常好用的 
	*/
	q["one"]=1;q["two"]=2;q["three"]=3;q["four"]=4;q["five"]=5;q["six"]=6;q["seven"]=7;q["eight"]=8;q["nine"]=9;q["ten"]=10;
    q["eleven"]=11;q["twelve"]=12;q["thirteen"]=13;q["fourteen"]=14;q["fifteen"]=15;q["sixteen"]=16;q["seventeen"]=17;q["eighteen"]=18;q["nineteen"]=19;q["twenty"]=20;
    q["a"]=1;q["both"]=2;q["another"]=1;q["first"]=1;q["second"]=2;q["third"]=3;
	
	cin>>s;
	while(s!=".")
	{
		if(q[s])
		{
			int k=q[s]*q[s]%100;
			if(k==0)	continue;
			st[cnt++]=k;
		}
		cin>>s;
	}
	
	sort(st,st+cnt);
	
	cout<<st[0];
	for(int i=1;i<cnt;i++)
	{
		if(st[i]<10)	cout<<0;
		cout<<st[i];
	}
	
	return 0;
} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值