求助,70分,#3,#6,#8错了
查看原帖
求助,70分,#3,#6,#8错了
956750
haiweixin楼主2023/3/4 08:43
#include<stdio.h>
#include <math.h>
#pragma warning(disable:4996)


int main(void)
{
	float a, b, c, p, x, y;
	scanf("%f %f %f", &a, &b, &c);

	p = b * b - 4 * a * c;
	if (p>0)
	{
		p = sqrt(p);
		x = (-1*b + p) / 2 / a;
		y = (-1*b - p) / 2 / a;
		printf("x1=%.5f;x2=%.5f", x < y ? x : y, x >  y ? x : y);
	}
	else if (p==0)
	{
		printf("x1=x2=%.5f", -1*b  / 2 / a);
	}
	else
	{
		printf("No answer!");
	}

	


	return 0;
}
2023/3/4 08:43
加载中...