第十六週 閱讀程序

/

* 程序的版權和版本聲明部分
* Copyright (c)2013, 煙臺大學計算機學院學生
* All rightsreserved.
* 文件名稱:
* 作者:袁靜
* 完成日期: 2013年6月13日
 版本號: v1.0
* 輸入描述:無
* 問題描述
* 程序輸出:

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    float a,b,c,disc;
    cout<<"please input a,b,c:";
    cout<<"                    "<<endl;
    cin>>a>>b>>c;
    cout<<"                    "<<endl;
    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;
    cerr爲 ostream 定義的三個輸出流對象 之一
    else
    {
        cout<<"x1="<<(-b+sqrt(disc))/(2*a)<<endl;
        cout<<"x2="<<(-b-sqrt(disc))/(2*a)<<endl;
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章