70分求解(c++)
查看原帖
70分求解(c++)
1448658
sugarcane716楼主2025/6/22 12:35
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	double a,b,c;
	cin>>a>>b>>c;
	double x1,x2;
	x1=(-b+sqrt(b*b-4*a*c))/(2*a);
	x2=(-b-sqrt(b*b-4*a*c))/(2*a);
	if(a==0)
	{
		printf("No answer!");
	}
	else if(x1==x2)
	{
		printf("x1=x2=%.5lf",x1);
	}
	else if(x1>x2)
	{
		printf("x2=%.5lf;x1=%.5lf",x2,x1);
	}
	else if(x2>x1)
	{
		printf("x1=%.5lf;x2=%.5lf",x1,x2);
	}
	else
	{
		printf("No answer!");
	}
	return 0;
}

55555,从刚注册账号不就就做了,现在还没解出来。大佬门帮忙看下北~

2025/6/22 12:35
加载中...