#3665: 最後一個測試點不會過- -


S46Es8954Elo2g (【洞洞】逢)


#include <iostream>
#include <math.h>
using namespace std;
int main ()

{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(b*b-4*a*c>0)
        cout<<"Two different roots x1="<<(-b+sqrt(b*b-4*a*c))/2*a<<" , x2="<<(-b-sqrt(b*b-4*a*c))/2*a<<endl;
        else if(b*b-4*a*c==0)
        cout<<"Two same roots x="<<-b/2*a<<endl;
        else if(b*b-4*a*c<0)
        cout<<"No real root\n";
    }

 

  return 0;
  }

#3666: Re:最後一個測試點不會過- -


S46Es8954Elo2g (【洞洞】逢)


#include
#include
using namespace std;
int main ()

{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(b*b-4*a*c>0)
        cout<<"Two different roots x1="<<(-b+sqrt(b*b-4*a*c))/2*a<<" , x2="<<(-b-sqrt(b*b-4*a*c))/2*a<        else if(b*b-4*a*c==0)
        cout<<"Two same roots x="<<-b/2*a<        else if(b*b-4*a*c<0)
        cout<<"No real root\n";
    }

 

  return 0;
 

 

我找到了- -

<<-b/(2*a) ←要括號