P1603 斯诺登的密码

P1603 斯诺登的密码

zyz529 @ 2020-02-18 23:23:35

怎么只得了20分??? 请教大神```

include <bits/stdc++.h>

using namespace std; string a[]= {"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 b[]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,1,1,2,3}; int c[7],n; string t; int main() { for(int i=1; i<=6; i++) { cin>>t; for(int j=0; j<26; j++) { if(t==a[j]) { c[++n]=b[i]; c[n]*=c[n]; c[n]%=100; } } } sort(c+1,c+n+1); if(n==0) { cout<<"0"; return 0; } cout<<c[1]; for(int i=2; i<=n; i++) { if(c[i]<10) { cout<<"0"; } cout<<c[i]; } return 0; }


by zyz529 @ 2020-02-18 23:23:55

#include <bits/stdc++.h>
using namespace std;
string a[]= {"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 b[]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,1,1,2,3};
int c[7],n;
string t;
int main() {
    for(int i=1; i<=6; i++) {
        cin>>t;
        for(int j=0; j<26; j++) {
            if(t==a[j]) {
                c[++n]=b[i];
                c[n]*=c[n];
                c[n]%=100;
            }
        }
    }
    sort(c+1,c+n+1);
    if(n==0) {
        cout<<"0";
        return 0;
    }
    cout<<c[1];
    for(int i=2; i<=n; i++) {
        if(c[i]<10) {
            cout<<"0";
        }
        cout<<c[i];
    }
    return 0;
}

by LJY_ljy @ 2020-02-18 23:50:17

@zyz529

这一段我帮您改了一下:

 if(t==a[j]) {
     c[++n]=b[i];
     c[n]*=c[n];
     c[n]%=100;
}

第二行应该是


c[++n] = b[j];

变量名搞错了,其他小细节没有什么问题。

by zyz529 @ 2020-02-19 20:16:34

@LJY_ljy 谢谢


|