P1603 斯诺登的密码

P1603 斯诺登的密码

题解

注意字符比较相同用 单引号 ‘ ’

字符串比较相同用 双引号 “ ”

 

注意本题非正规和正规对的都能被人翻译成数字

 

代码

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>

using namespace std;

inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'||ch>'9') last=ch,ch=getchar();
    while(ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
    if(last=='-') ans=-ans;
    return ans;
}
inline int readch()
{
    char c;
    do
    {
        c=getchar();
    }while(c==' '||c=='\n'||c=='\0'||c=='\t');
}

int a[7];
string s;
int change(string x)
{
    if(x=="one"||x=="One"||x=="a"||x=="A"||x=="first"||x=="First") return 1;
    if(x=="two"||x=="Two"||x=="both"||x=="Both"||x=="second"||x=="Second") return 2;
    if(x=="three"||x=="Three"||x=="another"||x=="Another"||x=="third"||x=="Third") return 3;
    if(x=="four"||x=="Four") return 4;
    if(x=="five"||x=="Five") return 5;
    if(x=="six"||x=="Six") return 6;
    if(x=="seven"||x=="Seven") return 7;
    if(x=="eight"||x=="Eight") return 8;
    if(x=="nine"||x=="Nine") return 9;
    if(x=="ten"||x=="Ten") return 10;
    if(x=="eleven"||x=="Eleven") return 11;
    if(x=="twelve"||x=="Twelve") return 12;
    if(x=="thirteen"||x=="Thirteen") return 13;
    if(x=="fourteen"||x=="Fourteen") return 14;
    if(x=="fifteen"||x=="Fifteen") return 15;
    if(x=="sixteen"||x=="Sixteen") return 16;
    if(x=="seventeen"||x=="Seventeen") return 17;
    if(x=="eighteen"||x=="Eighteen") return 18;
    if(x=="nineteen"||x=="Nineteen") return 19;
    if(x=="twenty"||x=="Twenty") return 20;
    return -1;
}

int main()
{
    for(int i=1;i<=6;i++)
    {
        cin>>s;
        int kk=change(s);
        if(kk*kk%100<=0||kk<=0){ a[i]=100;continue; } 
        else a[i]=kk*kk%100;
    }
    sort(a+1,a+7);
    bool flag=0;
    for(int i=1;i<=6;i++)
    {
        if(a[i]>=100)break;
        else
        {
            if(flag==0)
            { printf("%d",a[i]); flag=1;}
            else
            {
                if(a[i]<10) printf("0");
                printf("%d",a[i]);
            }
        }
    }
    if(!flag) printf("0");
    return 0;
}

 

 

posted @ 2019-07-27 18:24  晔子  阅读(332)  评论(0编辑  收藏  举报