#19664: 看過來


b19@apps.ntpc.edu.tw (小帳)


#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int a,b,c,x,x1,x2;
 
while(cin>>a>>b>>c){
    x=(-1*b)/(2*a);
    x1=(-1*b+sqrt(b*b-4*a*c))/2*a;
    x2=(-1*b-sqrt(b*b-4*a*c))/2*a;
    
    if(b*b-4*a*c>0){
      cout<<"Two different roots x1="<<x1<<" , "<<"x2="<<x2<<endl;
    }
    else if(b*b-4*a*c==0){
      cout<<"Two same roots x="<<x<<endl;
    }
  else{
    cout<<"No real root"<<endl;
  }
 
}
return0;
}
#19666: Re:看過來


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)


#include
#include
#include
using namespace std;

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

管理員辛苦了