第十四周阅读程序cerr流对象

来源:互联网 发布:人员排班软件 编辑:程序博客网 时间:2024/05/20 12:51
问题及代码:
/**Copyright (c)2015,烟台大学计算机与控制工程学院*All rights reserved.*文件名称:cerr.cpp*作    者:赵敏*完成日期:2015年6月10日*版 本 号:v1.0*问题描述:*/#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;}


运行结果:

 

0 0
原创粉丝点击