Conic Section

描述

The conic sections are the nondegenerate curves generated by the intersections of a plane with one or two nappes of a cone. For a plane perpendicular to the axis of the cone, a circle is produced. For a plane that is not perpendicular to the axis and that intersects only a single nappe, the curve produced is either an ellipse or a parabola. The curve produced by a plane intersecting both nappes is a hyperbola.

There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.

Each test case consists of a line containing 6 real numbers a, b, c, d, e, f. The absolute value of any number never exceeds 10000. It’s guaranteed that a2+c2>0, b=0, the conic section exists and it is non-degenerate.

输出

For each test case, output the type of conic section ax2+bxy+cy2+dx+ey+f=0. See sample for more details.

样例输入
5
1 0 1 0 0 -1
1 0 2 0 0 -1
0 0 1 1 0 0
1 0 -1 0 0 1
2 0 2 4 4 0
样例输出
circle
ellipse
parabola
hyperbola
circle

在这里插入图片描述
分析:分多种情况判断。
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
double a,b,c,d,e,f;
while(cin>>T)
{
while(T–)
{
cin>>a>>b>>c>>d>>e>>f;
if (ac)
cout<<“circle”<<endl;
else
if (ac>0)
cout<<“ellipse”<<endl;
else
if (a
c
0)
{
cout<<“parabola”<<endl;
}
else
{
cout<<“hyperbola”<<endl;
}
}
}
return 0;
}

发布了40 篇原创文章 · 获赞 0 · 访问量 679

猜你喜欢

转载自blog.csdn.net/Skynamer/article/details/103448526