感觉自己写的没问题啊,但是一直WA
查看原帖
感觉自己写的没问题啊,但是一直WA
329854
Harmony_Lu楼主2021/3/9 10:04

代码如下 大神帮忙看看

// UVA465
#include <iostream>
using namespace std;
#define MAX 2147483647
int main(){
    char s1[1000], s2[1000], ch;
    while( cin>>s1>>ch>>s2 ){
        double a, b, c;
        cout<<s1<<' '<<ch<<' '<<s2<<endl;
        a = atof(s1);
        b = atof(s2);
        if( a>MAX){
            cout<<"first number too big"<<endl;
        }
        if( b>MAX){
            cout<<"second number too big"<<endl;
        }
        if( a>MAX||b>MAX ){
            cout<<"result too big"<<endl;
        }
        else{
            if( (ch=='+'&&((a+b)>MAX))||(ch=='*'&&((a*b)>MAX)))
                cout<<"result too big"<<endl;   
        }
    }
}
2021/3/9 10:04
加载中...