为什么会变成这样(样例都过不了,似乎未输入完)?

P1603 斯诺登的密码

Jason12 @ 2022-01-09 16:22:48

#include <bits/stdc++.h>
  using namespace std;
int main()
{
    string s[7];
    int a[7],t=0;
    for (int i=1;i<=6;i++)
    {
        cin>>s[i];
        if (i=1) s[1][0]=s[1][0]+' ';
        if (s[i]=="one" || s[i]=="first" || s[i]=="another" || s[i]=="a") a[t++]=1;
        else if (s[i]=="two" || s[i]=="second" || s[i]=="both") a[t++]=4;
        else if (s[i]=="three" || s[i]=="third") a[t++]=9;
        else if (s[i]=="four") a[t++]=16;
        else if (s[i]=="five") a[t++]=25;
        else if (s[i]=="six") a[t++]=36;
        else if (s[i]=="seven") a[t++]=49;
        else if (s[i]=="eight") a[t++]=64;
        else if (s[i]=="nine") a[t++]=81;
        else if (s[i]=="zero" && s[i]=="ten" || s[i]=="twenty") a[t++]=0;
        else if (s[i]=="eleven") a[t++]=21;
        else if (s[i]=="twelve") a[t++]=44;
        else if (s[i]=="thirteen") a[t++]=69;
        else if (s[i]=="fourteen") a[t++]=96;
        else if (s[i]=="fifteen") a[t++]=25;
        else if (s[i]=="sixteen") a[t++]=56;
        else if (s[i]=="seventeen") a[t++]=89;
        else if (s[i]=="eighteen") a[t++]=24;
        else if (s[i]=="nineteen") a[t++]=61;
        //cout<<t<<" "<<a[t]<<" "<<s[i]<<" "<<endl;//test
    }
    if (t==0) cout<<0<<endl;
    else 
    {
        for (int i=1;i<t;i++)
            if (a[i]>a[i]+1) swap(a[i],a[i+1]);
        /*for (int i=1;i<=t;i++)
        {
            if (i!=1 && a[t]<10) cout<<0;
            cout<<a[i]<<" ";
        }
        cout<<endl;*/
        for (int i=1;i<=t;i++)
        {
            if (i!=1 && a[t]<10) cout<<0;
            cout<<a[i];
        }
    }
    cout<<endl;
    return 0;
}

样例输入:Black Obama is two five zero . 样例输出:425 我的输出:无


by Raymondzll @ 2022-01-09 16:30:20

@Jason12 if(i=1)这种能不能自己检查一下啊


by dingyi2007 @ 2022-01-09 16:45:11

您这第十行怕是得CE吧


by Jason12 @ 2022-01-09 17:38:19

@Raymondzll 谢谢大佬,可是主要问题好像不在这里,输出了2501 o(╥﹏╥)oqwq


|