本地和在线IDE均可输出样例,提交后编译错误是为什么(cpp)

P1603 斯诺登的密码

85LP @ 2021-02-25 11:25:24

本地和在线IDE均可输出样例,提交后却编译错误,请大神指点

#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;
bool cmp(int x,int y)
{
    return x<y;
}
int main()
{
    string str[26]={"one","two","three","four","five","six","seven",
    "eight","nine","ten","elven","twelve","thirteen","fourteen",
    "fifteen","sixteen","seventeen","eighteen","nineteen","twenty","a",
    "both","another","first","second","third"};
    int a[26]={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,},b[6],l,i,m=0,targe=0;
    string s[6];
    for(i=0;i<6;i++)
        cin>>s[i];  
    for(i=0;i<6;i++)
    {
        for(l=0;l<26;l++)
        {
            if(s[i]==str[l])
            {
                b[m++]=a[l]*a[l]%100;
                targe++;
            }
        }
    }
    if(targe==0) 
    {
        cout<<"0";
        return 0;
    }
    sort(b,b+m,cmp);
    string num[6]={"0","0","0","0","0","0"},end;
    for(l=0;l<m;l++)
    {
        int x=b[l];
        if(b[l]<10)
        {
            end= to_string(x);
            if(l!=0)
            num[l]+=end;
            if(l==0)
            num[l]=end;
        }
        else num[l]=to_string(x);
    }
    string().swap(end);
    for(l=0;l<m;l++)
    {
        end+=num[l];
    }
    cout<<end;
    return 0;
}

by 屑梨子 @ 2021-02-25 11:27:06

to_string是C++11内容吧,用C++11提交一下试试


by 屑梨子 @ 2021-02-25 11:27:21

@WX920106840406


by 85LP @ 2021-02-25 11:28:20

@屑梨子 嗯嗯,过啦,谢谢您


|