#24122:


jz46946@gmail.com (James JSY)

學校 : 不指定學校
編號 : 139005
來源 : [140.121.165.26]
最後登入時間 :
2024-11-12 14:51:36
a006. 一元二次方程式 | From: [112.104.115.195] | 發表日期 : 2021-01-21 11:17

#include<stdio.h>

int main(){

int a, b, c;

while(scanf ("%d%d%d",&a,&b,&c)!=EOF){

float D;

D = b*b-4*a*c;

if(D > 0){

int x1, x2;

x1 = (-b+sqrt(D))/(2*a);

x2 = (-b-sqrt(D))/(2*a);

printf("Two different roots x1=%d , x2=%d\n", x1, x2);

}

if(D == 0){

int x3;

x3 = -b/(2*a);

printf("Two same roots x=%d\n", x3);

}

if(D < 0){

printf("No real root\n");

}

}

return 0;

}

 
ZeroJudge Forum