#include<stdio.h> #include<stdlib.h>
int main() { FILE *in; double a,b,c,n,i,x1,x2,D; in=fopen("in.txt","r"); fscanf(in,"%lf",&n); for(i=1;i<=n;i++) { fscanf(in,"%lf %lf %lf",&a,&b,&c); D=pow(b,2)-4*a*c; x1=(-b+sqrt(D))/(2*a); x2=(-b-sqrt(D))/(2*a); printf("兩根解為:%.3lf或%.3lf\n",x1,x2); } fclose(in); system("pause"); return 0; } |