80分求助!
查看原帖
80分求助!
809261
Florian18楼主2023/8/1 12:04
#include<stdio.h> 
#include<stdbool.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,m,n) for(int i=(m);i<(n);i++)

int main()
{
	double a,b,c,x1,x2,d,t;
	scanf("%lf %lf %lf",&a,&b,&c);
	if(b*b-4*a*c>=0)
	{
	d = b*b-4*a*c;
	x1=(-b+sqrt(d))/(2*a);
	x2=(-b-sqrt(d))/(2*a);
	}
	else
	printf("No answer!");
	if(d==0)
	printf("x1=x2=%.5lf",x1);
	else if(d>0)
	{
		if(x1>x2)
		{
		t=x2;
		x2=x1;
		x1=t;
		}
	printf("x1=%.5lf;x2=%.5lf",x1,x2);
	}
	else
	printf("No answer!");
	return 0;
}
2023/8/1 12:04
加载中...