2018西北工业大学夏令营第四题

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	
	int n;
	double a,b,c;
	cin>>n;
	for(int i = 0;i < n;i++){
		cin>>a>>b>>c;
		if(b*b-4*a*c<0){
			printf("NaN\n");
			continue;
		}
		double x1 = (b*(-1)+sqrt(b*b-4*a*c))/(a*2.0);
		double x2 = (b*(-1)-sqrt(b*b-4*a*c))/(a*2.0);
		printf("%.2f %.2f\n",x1,x2);
	}
	return 0;
}
发布了313 篇原创文章 · 获赞 64 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/PriestessofBirth/article/details/104922491
今日推荐