这个程序有很大的问题,麻烦解决下,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/04/29 22:20:48
#include<stdio.h>
void main()
{
int a,b,c;
float *x1,*x2;
printf("please input a,b,c:");
scanf("%d,%d,%d",&a,&b,&c);
if(b*b-4*a*c>=0)
{fun(a,b,c);
printf("%f,%f",*x1,*x2);}
else printf("default");
}
int fun(int a,int b,int c)
{
float *x1,*x2,d;
d=b*b-4*a*c;
*x1=(-a+sqrt(d))/2/a;
*x2=(-a-sqrt(d))/2/a;
}

#include<stdio.h>
#include "math.h"
float x1,x2;
float fun(float a,float b,float c)
{
float d;
d=b*b-4*a*c;
x1=(-b+sqrt(d))/2/a;
x2=(-b-sqrt(d))/2/a;
return 1;
}
void main()
{
float a,b,c;
printf("please input a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
if(b*b-4*a*c>=0)
{fun(a,b,c);
printf("%f,%f\n",x1,x2);}
else printf("default");
}