本地能过,洛谷显示编译问题

P1957 口算练习题

volume_001 @ 2022-07-13 09:33:05

请大佬帮忙找一下什么问题

# include <iostream>
 using namespace std;
# include <string>
//char q[50];
string q;
string m;
//char m[50];
 int main()
 {
    int n;
    cin>>n;
 string p,k,z;
    int d,c;

    for(int i=0;i<n;i++)
    {
        cin>>p;
        if(p=="a")
        {
            cin>>q>>m;
                int d=stoi(q);
                    //cout<<"到这了" ;
                int c=stoi(m);
            int e=c+d;
        string l=to_string(e);
    //  cout<<l;
                cout<<d<<"+"<<c<<"="<<d+c<<endl;
                cout<<q.length()+m.length()+2+l.length()<<endl;
                    z=p;
        }
    else if(p=="b")
        {
                cin>>q>>m;
                int d=stoi(q);
                int c=stoi(m);
                string l=to_string(d-c);
                cout<<d<<"-"<<c<<"="<<d-c<<endl;
                cout<<q.length()+m.length()+2+l.length()<<endl;
                    z=p;    
        }
        else if(p=="c")
        {
                cin>>q>>m;
                int d=stoi(q);
                int c=stoi(m);
                string l=to_string(d*c);
                cout<<d<<"*"<<c<<"="<<d-c<<endl;
                cout<<q.length()+m.length()+2+l.length()<<endl; 
                    z=p;
        }
        else
        {
                if(z=="a")
        {
                cin>>m;
                int d=stoi(p);
                int c=stoi(m);
        string l=to_string(c+d);
            cout<<d<<"+"<<c<<"="<<d+c<<endl;
            cout<<p.length()+m.length()+2+l.length()<<endl;
                //  z=p;
        }
    else if(z=="b")
        {
            cin>>m;
                int d=stoi(p);
                int c=stoi(m);
                string l=to_string(d-c);
                cout<<d<<"-"<<c<<"="<<d-c<<endl;
                cout<<p.length()+m.length()+2+l.length()<<endl;
                 // z=p;    
        }
        else if(z=="c")
        {
                    cin>>m;
                int d=stoi(p);
                int c=stoi(m);
                string l=to_string(d*c);
                cout<<d<<"*"<<c<<"="<<d*c<<endl;
                cout<<p.length()+m.length()+2+l.length()<<endl; 
                //  z=p;
        }

        }
//      cin>>a[i];

     }
 // cin>>a;
//  int len=strlen(a);
//  cout<<len;
//  
 }

by rxjdasiwzl @ 2022-07-13 09:40:06

@volume_001 语言选 C++11 或以上


by jiangjiangQwQ @ 2022-07-13 16:24:54

在Dev-C++没显示语法错误那就是提交时默认语言选错了


|