/* 作者:一仁 06 沈婷筠 程式功能:File 日期:101/03/28 */
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { FILE *fptr; double a,b,c,D,X,x,n,i=1; fptr=fopen("E:\\10030306\\in.txt","r"); if(fptr!=NULL) { fscanf(fptr,"%lf",&n); while(i<=n) { fscanf(fptr,"%lf %lf %lf",&a,&b,&c); D=pow(b,2)-4*a*c; X=(-b+sqrt(D))/(2*a); x=(-b-sqrt(D))/(2*a); if(D>=0) { printf("%.3lf,%.3lf\n",X,x); } else printf("none\n"); i=i+1; } fclose(fptr); } else printf("File opening failure!"); system("PAUSE"); return 0; }
|