#8579: 輸出正確,為何它說錯誤?


funspsky (clision)


/code_1728194.cpp: In function ‘int main()’: /code_1728194.cpp:4: error: ‘cin’ was not declared in this scope /code_1728194.cpp:7: error: ‘cout’ was not declared in this scope /code_1728194.cpp:11: error: ‘cout’ was not declared in this scope /code_1728194.cpp:15: error: ‘sqrt’ was not declared in this scope /code_1728194.cpp:17: error: ‘cout’ was not declared in this scope 
 
 
#include<iostream>
#include<math.h>
using namespace std;
main()
{
      int a, b, c, x, x1, x2;
      while(cin >> a >> b >> c)
      {
                if ((b*b-(4*a*c))<0)
                cout << "No real root";
                if ((b*b-(4*a*c))==0)
                {
                                     x=-b/2*a;
                cout << "Two same roots x=" << x;
                }
                if ((b*b-(4*a*c))>0)
                {
                x1=(-b+ sqrt(b*b-(4*a*c)))/2*a;
                x2=(-b- sqrt(b*b-(4*a*c)))/2*a;
                cout << "Two different roots x1=" << x1 << " , x2=" << x2;
                }
                }
                return 0;
                }  
 
#8586: Re:輸出正確,為何它說錯誤?


yuchiao0921 (我的字典沒有放棄)


每個輸出之後要換行

 然後C++應該是要include cmath