神编译器,0分求助(自己编译明明能过)

P1603 斯诺登的密码

ddgtang @ 2020-02-03 19:12:49

#include<bits/stdc++.h>
using namespace std;
map<string,int>num;
int ans[6]={0};
int main(){
    int f;
    string s;
    num["one"]=1;
    num["two"]=2;
    num["three"]=3;
    num["four"]=4;
    num["five"]=5;
    num["six"]=6;
    num["seven"]=7;
    num["eight"]=8;
    num["nine"]=9;
    num["ten"]=10;
    num["eleven"]=11;
    num["twelve"]=12;
    num["thirteen"]=13;
    num["fourteen"]=14;
    num["fifteen"]=15;
    num["sixteen"]=16;
    num["seventeen"]=17;
    num["eighteen"]=18;
    num["nineteen"]=19;
    num["twenty"]=20;
    num["a"]=1;
    num["both"]=2;
    num["another"]=1;
    num["first"]=1;
    num["second"]=2;
    num["third"]=3;
    for(int i=1;i<=6;i++){
        cin>>s;
        if(num[s]!=0){
            int p=(num[s]*num[s])%100;
            if(p==0)continue;
            ans[f]=p;
            f++; 
        }
        //cout<<s<<endl;
    }
    //cout<<"F:"<<f<<endl;
    for(int i=0;i<f;i++){
        cout<<ans[i]<<endl;
    }
    sort(ans,ans+f);
    cout<<ans[0];
    for(int i=1;i<f;i++){
        if(ans[i]<10) cout<<'0';
        cout<<ans[i];
    }
    return 0;
}

紧急求助!!!

下载了测试样例,自己编译是对的,但系统不让过。 和题解有点像,但别误会,不是抄的!

各位大佬、大神们帮帮忙!!


by AC_Dolphin @ 2020-02-03 19:19:20

@ddgtang ?为什么我跑了一遍是RE


by 123789456ye @ 2020-02-03 19:34:58

@ddgtang 你的f定义在main函数里,没初始化


by USSENTERPRISE @ 2020-02-03 19:36:54

玄学变量定义法


by ddgtang @ 2020-02-03 21:24:12

@123789456ye f初始化了还是不行,请大佬给出进一步指示!!!


by ddgtang @ 2020-02-03 21:28:39

@AC_Dolphin 所以我才发帖子


by 123789456ye @ 2020-02-04 08:40:35

@ddgtang

#include<bits/stdc++.h>
using namespace std;
map<string, int>num;
int ans[6] = { 0 };
int main() {
    int f = 0;//注意
    string s;
    num["one"] = 1;
    num["two"] = 2;
    num["three"] = 3;
    num["four"] = 4;
    num["five"] = 5;
    num["six"] = 6;
    num["seven"] = 7;
    num["eight"] = 8;
    num["nine"] = 9;
    num["ten"] = 10;
    num["eleven"] = 11;
    num["twelve"] = 12;
    num["thirteen"] = 13;
    num["fourteen"] = 14;
    num["fifteen"] = 15;
    num["sixteen"] = 16;
    num["seventeen"] = 17;
    num["eighteen"] = 18;
    num["nineteen"] = 19;
    num["twenty"] = 20;
    num["a"] = 1;
    num["both"] = 2;
    num["another"] = 1;
    num["first"] = 1;
    num["second"] = 2;
    num["third"] = 3;
    for (int i = 1; i <= 6; i++) {
        cin >> s;
        if (num[s] != 0) {
            int p = (num[s] * num[s]) % 100;
            if (p == 0)continue;
            ans[f] = p;
            f++;
        }
        //cout<<s<<endl;
    }
    /*cout << "F:" << f << endl;
    for (int i = 0; i < f; i++) {
        cout << ans[i] << endl;
    }*///注意
    sort(ans, ans + f);
    cout << ans[0];
    for (int i = 1; i < f; i++) {
        if (ans[i] < 10) cout << '0';
        cout << ans[i];
    }
    return 0;
}

我交了一发可过


by 123789456ye @ 2020-02-04 08:41:44

@ddgtang 话说你没发现跑样例多输出了一些东西吗


by ddgtang @ 2020-02-04 10:33:44

@123789456ye 感谢大佬,题目已过!!!


|