问一下 大佬萌 这代码为什么RE了呀

P1603 斯诺登的密码

Danny_Archer @ 2020-01-15 11:49:26

#include<iostream>
#include<string>
#include<algorithm>
#include<iterator>
using namespace std;

int a[6];

int main(){
    string s;
    cin >> s;
    int count = 0;
    int j = 0, temp = 0;
    for(int i = 0; i < 6; i++){
        string s1;
        while(s[j] != ' ' || s[j] != '.'){
            j++;
        }
        for(; temp < j; temp++){
            int z = 0;
            s1[z] = s[temp];
            z++;
        }
        temp++;
        j++;

    if(s1 == "one" || s1 == "a" || s1 == "first"){
        a[count] = 1;
        count++;
    }
    else if(s1 == "two" || s1 == "second" || s1 == "both"){
        a[count] = 2;
        count++;
    }
    else if(s1 == "three" || s1 == "third" || s1 == "another"){
        a[count] = 3;
        count++;
    }
    else if(s1 == "four"){
        a[count] = 4;
        count++;
    }
    else if(s1 == "five"){
        a[count] = 5;
        count++;
    }
    else if(s1 == "six"){
        a[count] = 6;
        count++;
    }
    else if(s1 == "seven"){
        a[count] = 7;
        count++;
    }
    else if(s1 == "eight"){
        a[count] = 8;
        count++;
    }
    else if(s1 == "nine"){
        a[count] = 9;
        count++;
    }
    else if(s1 == "ten"){
        a[count] = 10;
        count++;
    }
    else if(s1 == "eleven"){
        a[count] = 11;
        count++;
    }
    else if(s1 == "twelve"){
        a[count] = 12;
        count++;
    }
    else if(s1 == "thirteen"){
        a[count] = 13;
        count++;
    }
    else if(s1 == "fourteen"){
        a[count] = 14;
        count++;
    }
    else if(s1 == "fifteen"){
        a[count] = 15;
        count++;
    }
    else if(s1 == "sixteen"){
        a[count] = 16;
        count++;
    }
    else if(s1 == "seventeen"){
        a[count] = 17;
        count++;
    }
    else if(s1 == "eighteen"){
        a[count] = 18;
        count++;
    }
    else if(s1 == "nineteen"){
        a[count] = 19;
        count++;
    }
    else if(s1 == "twenty"){
        a[count] = 20;
        count++;
    }}
    for(int i = 0; i < count; i++){
        a[i] = a[i]*a[i];
        a[i] %= 100;
    }

    sort(a, a+count);

    for(int i = 0; i < count; i++){
        if(a[i] == 0)   continue;
        cout << a[i];
    }
    return 0;
}

by 莫负韶华 @ 2020-01-15 20:34:56

我这边可以啊……


by WuXingRui_wxr @ 2020-03-06 17:30:52

@Danny_Archer

数组开小了。


|