#include<stdio.h>
#include<math.h>
int main(){
int a,b,c;
int x1,x2,x3;
int answer;
int x;
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
answer=sqrt(b*b-4*a*c);
if(answer>0){
x1=(-b+answer)/2a;
x2=(-b-answer)/2a;
printf("Two different roots x1=%d,x2=%d,x1,x2);
}
else if(answer==0){
x3=-b/2a;
printf("Two same roots x=%d,x3);
}
else {
printf("No real root");
}
}
}
#include
#include
int main(){
int a,b,c;
int x1,x2,x3;
int answer;
int x;
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
answer=sqrt(b*b-4*a*c);
if(answer>0){
x1=(-b+answer)/2a;
x2=(-b-answer)/2a;
printf("Two different roots x1=%d,x2=%d,x1,x2);
}
else if(answer==0){
x3=-b/2a;
printf("Two same roots x=%d,x3);
}
else {
printf("No real root");
}
}
}
x1=(-b+answer)/2a;
x2=(-b-answer)/2a;
x3=-b/2a;
2a應該要改成 (2*a)試試看