1013. Recognize triangles, 1013 recognize triangles
1013. Identification triangle (Standard IO) Time Limit: 1000 MS space limit: 262144 KB Specific Limit
Enter three positive integers in the topic description to determine whether the three sides of the triangle can be formed. If not, output "NO ". If a triangle can be formed, which triangle can be determined? Output the corresponding triangle types "Equilateral", "Right", and "General" in sequence by equals, Right, and General ". Enter three integers a, B, and c separated by spaces in a row to indicate the length of the three sides of the triangle. The output corresponds to the triangle type. If a triangle cannot be formed, the output "NO" is displayed. If an equedge triangle is used, the output "Equilateral" is displayed. If a Right triangle is used, the output "Right" is displayed ", other triangles output "General ". Sample Input
3 4 5
Sample output
Right
Data range: 1 <= a, B, c <= 1000
Source/Author: exercises 3.3.2
Copyright©China Computer Society
The China Computer Society has the copyright to this topic (including questions and data ).
This Copyright/authorization form applies to all questions added by administrators
#include<iostream>#include<cmath>#include<cstdio>#include<algorithm>using namespace std;int tot=0;double ans;int a[4];int main(){ cin>>a[1]>>a[2]>>a[3]; sort(a+1,a+4); //cout<<a[1]<<a[2]<<a[3]; int b=a[2]; int c=a[3]; if(a[1]+b>c) { if(a[1]*a[1]+b*b==c*c) { cout<<"Right"; return 0; } else if(a[1]==b&&b==c) { cout<<"Equilateral"; return 0; } else { cout<<"General"; return 0; } } else { cout<<"NO"; } return 0;}