/*
02.*Copyright (c)2014,烟台大学计算机与控制工程学院
03.*All rights reserved.
04.*文件名称:d.cpp
05.*作 者:张旺华
06.*完成日期:2015年6月3日
07.*版 本 号:v1.0
08.*/
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float a,b,c,disc;
cout<<"please input a,b,c:";
cin>>a>>b>>c;
if (a==0)
cerr<<"a is equal to zero,error!"<<endl;
else if ((disc=b*b-4*a*c)<0)
cerr<<"disc=b*b-4*a*c<0"<<endl;
else
{
cout<<"x1="<<(-b+sqrt(disc))/(2*a)<<endl;
cout<<"x2="<<(-b-sqrt(disc))/(2*a)<<endl;
}
return 0;
}
最为简单的输入输出
/*
02.*Copy