80分求助 想用isnan函数
查看原帖
80分求助 想用isnan函数
849325
ZAQBFan楼主2022/10/24 10:14
#define _CRT_SECURE_NO_WARNINGS//取消scanf等报错
#include<stdio.h>
#include<math.h>

int main()
{
	double a, b, c;
	scanf("%lf%lf%lf", &a, &b, &c);

	double x1 = (-b + sqrt(b * b - 4 * a * c)) / (2*a);
	double x2 = (-b - sqrt(b * b - 4 * a * c)) / (2*a);


	//printf("%.5lf", x1);
	

	if (isnan(x1)||isnan(x2))
	{
		printf("No answer");
	}

	else 
	{

		if (x1 == x2)
		{
			printf("x1=x2=%.5lf", x1);
		}
		else
		{
			x1 < x2 ? printf("x1=%.5lf;x2=%.5lf", x1, x2) : printf("x1=%.5lf;x2=%.5lf", x2, x1);
		}

	}







	return 0;
}
2022/10/24 10:14
加载中...