洛谷 - P1603 - 斯诺登的密码 - 字符串格式转换

有毒,大小写不检测,句号也不管。

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

int num[10];
int top=0;

char s[30];

int tonum(){
    int n=strlen(s);
    if(strcmp(s,"one")==0)
        return 1;
    else if(strcmp(s,"two")==0)
        return 2;
    else if(strcmp(s,"three")==0)
        return 3;
    else if(strcmp(s,"four")==0)
        return 4;
    else if(strcmp(s,"five")==0)
        return 5;
    else if(strcmp(s,"six")==0)
        return 6;
    else if(strcmp(s,"seven")==0)
        return 7;
    else if(strcmp(s,"eight")==0)
        return 8;
    else if(strcmp(s,"nine")==0)
        return 9;
    else if(strcmp(s,"ten")==0)
        return 10;
    else if(strcmp(s,"eleven")==0)
        return 11;
    else if(strcmp(s,"twelve")==0)
        return 12;
    else if(strcmp(s,"thirteen")==0)
        return 13;
    else if(strcmp(s,"fourteen")==0)
        return 14;
    else if(strcmp(s,"fifteen")==0)
        return 15;
    else if(strcmp(s,"sixteen")==0)
        return 16;
    else if(strcmp(s,"seventeen")==0)
        return 17;
    else if(strcmp(s,"eighteen")==0)
        return 18;
    else if(strcmp(s,"nineteen")==0)
        return 19;
    else if(strcmp(s,"twenty")==0)
        return 20;
    else if(strcmp(s,"a")==0)
        return 1;
    else if(strcmp(s,"another")==0)
        return 1;
    else if(strcmp(s,"first")==0)
        return 1;
    else if(strcmp(s,"both")==0)
        return 2;
    else if(strcmp(s,"second")==0)
        return 2;
    else if(strcmp(s,"third")==0)
        return 3;
    return 0;
}

ll ans;

void solve(){
    for(int i=0;i<6;i++){
        num[i]=(num[i]*num[i])%100;
    }

    sort(num,num+6);

    ll sum=0;
    for(int i=0;i<6;i++){
        sum=sum*100+num[i];
    }

    ans=sum;
}

int main(){
    for(int i=0;i<6;i++){
        scanf("%s",s);
        int n=strlen(s);
        for(int j=0;j<n;j++){
            s[j]=tolower(s[j]);
            if(s[j]=='.')
                s[j]='\0';
        }
        num[top++]=tonum();
    }
    solve();
    printf("%lld\n",ans);
}

猜你喜欢

转载自www.cnblogs.com/Yinku/p/10317524.html