-4

我已经编写了这个程序,它通过了所有手动测试条件,但是当我在 IDE 上在线提交时说“错误答案”。约束 0≤a,b,c≤180

    #include <iostream>
using namespace std;

int main() {
    // your code goes here
    double a,b,c;
    cin>>a>>b>>c;
    if(a+b+c==180)
    cout<<"YES";
    else
    cout<<"NO";
    
    return 0;
}
4

2 回答 2

-1
int main()
{
// your code goes here
double a,b,c;
cin>>a>>b>>c;
//made the changes with the help of suggestion from the forum
if((a>0)&&(b>0)&&(c>0)&&(a+b+c==180))
cout<<"YES";
else
cout<<"NO";


return 0;
}
于 2021-06-26T03:59:43.597 回答
-1

当 a,bc 为 0 且 a+b+c=180 时,上述代码没有给出正确答案。所以,

int main()
{
// your code goes here
double a,b,c;
cin>>a>>b>>c;
//add the below statement
if((a!=0)&&(b!=0)&&(c!=0)){
if(a+b+c==180)
cout<<"YES";
else
cout<<"NO";
}
else{
 cout<<"NO";
}
return 0;
}
于 2021-06-25T05:53:09.293 回答