错了

P1603 斯诺登的密码

ACtheQ @ 2023-06-20 21:55:39

%%%


#include <bits/stdc++.h>
using namespace std;
string number[30]={"-1","zero","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"};
int value[30]={-1,0,1,4,9,16,25,36,49,64,81,0,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
int num[10];
int main()
{
    for(int i=1;i<=6;i++)
    {
        string s;
        cin>>s;
        for(int i=1;i<=25;i++)
        {
            if(s==number[i]) num[i]=value[i];
        }
    }
    sort(num+1,num+7);
    bool flag=false;
    for(int i=1;i<=6;i++) 
    {
        if(num[i]==0) continue;
        if(flag) printf("%.2d",num[i]);
        else 
        {
            cout<<num[i];
            flag=true;
        }

    }
    if(!flag) cout<<0;
    return 0;
}

by Liyiyang1123 @ 2023-06-20 22:17:45

注意看这句:

(2)将这些数字平方后对 100 取模,如 00,05,11,19,86,9900,05,11,19,86,99

如果输入为 four four.那该输出什么呢?

以你的程序输出 44, 但仔细想一想,是不是这里不需要去掉 04 的前导零。


|