a006.
一元二次方程式
| From: [1.165.194.42] |
發表日期
:
2013-03-24 02:16
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n[3];
while(cin>>n[0]>>n[1]>>n[2]>>n[3])
if(n[1]*n[1]-4*n[0]*n[2]>>31)
cout<<"No real root\n";
else
{
int ans[2]={(-n[1]+sqrt(n[1]*n[1]-4*n[0]*n[2]))/(2*n[0]),(-n[1]-sqrt(n[1]*n[1]-4*n[0]*n[2]))/(2*n[0])};
if(ans[1]==ans[0])
cout<<"Two same root x="<<ans[1]<<endl;
else
cout<<"Two different roots x1="<<ans[0]<<" , x2="<<ans[1]<<endl;
}
}
---------------------------------
錯誤顯示:
WA (line:1)
輸出短少您共輸出 0 行。