zoukankan      html  css  js  c++  java
  • 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=='
    '||c==''||c=='	');
    }
    
    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;
    }
    
     
  • 相关阅读:
    Java的类演进过程
    P112、面试题16:反转链表
    P107、面试题15:链表中倒数第K个结点
    Java对象相关元素的初始化过程
    P102、面试题14:调整数组顺序使奇数位于偶数前面
    P99、面试题13:在o(1)时间删除链表结点
    面试常考的数据结构Java实现
    Linux命令面试常考的简单汇总
    操作系统与进程基础知识
    python--process
  • 原文地址:https://www.cnblogs.com/xiaoyezi-wink/p/11256206.html
Copyright © 2011-2022 走看看