杭电acm 4142Triangle(小学生题,判断三角形)
来源:互联网 发布:中科大软件学院信息化 编辑:程序博客网 时间:2024/05/20 09:08
Triangle
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 442 Accepted Submission(s): 262
Problem Description
A triangle is one of the basic shapes of geometry: a polygon with three corners or vertices and three sides or edges which are line segments.
Triangles can be classified according to the relative lengths of their sides:
· In an equilateral triangle all sides have the same length. An equilateral triangle is also a regular polygon with all angles measuring 60°.
· In an isosceles triangle, two sides are equal in length. An isosceles triangle also has two angles of the same measure; namely, the angles opposite to the two sides of the same length; this fact is the content of the Isosceles triangle theorem.
· In a scalene triangle, all sides are unequal. The three angles are also all different in measure. Some (but not all) scalene triangles are also right triangles.
Triangles can be classified according to the relative lengths of their sides:
· In an equilateral triangle all sides have the same length. An equilateral triangle is also a regular polygon with all angles measuring 60°.
· In an isosceles triangle, two sides are equal in length. An isosceles triangle also has two angles of the same measure; namely, the angles opposite to the two sides of the same length; this fact is the content of the Isosceles triangle theorem.
· In a scalene triangle, all sides are unequal. The three angles are also all different in measure. Some (but not all) scalene triangles are also right triangles.
Input
The first line of input contains an integer (1 <= T <= 100), the number of test cases. T test data sets follow, each data set consists of 3 integers A, B and C, where (1 <= A,B,C <= 1,000,000) the triangle side lengths.
Output
For each test case, print “equilateral”, “isosceles” or “scalene” describing the triangle type. If the input doesn’t create a valid triangle output “invalid!”. Follow the output format below.
Sample Input
23 3 46 4 2
Sample Output
Case #1: isoscelesCase #2: invalid!
Source
The Third Lebanese Collegiate Programming Contest
想法:
水题
代码:
#include<stdio.h>
#include<string.h>
int main()
{
int T;
scanf("%d",&T);
int ws=1;
while(T--)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("Case #%d: ",ws++);
if(a+b>c&&a+c>b&&b+c>a)
{
if(a==b&&b==c&&c==a)
{
printf("equilateral\n");
}
else if(a==b||b==c||c==a)
{
printf("isosceles\n");
}
else printf("scalene\n");
}
else
{
printf("invalid!\n");
}
}
return 0;
}
#include<string.h>
int main()
{
int T;
scanf("%d",&T);
int ws=1;
while(T--)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("Case #%d: ",ws++);
if(a+b>c&&a+c>b&&b+c>a)
{
if(a==b&&b==c&&c==a)
{
printf("equilateral\n");
}
else if(a==b||b==c||c==a)
{
printf("isosceles\n");
}
else printf("scalene\n");
}
else
{
printf("invalid!\n");
}
}
return 0;
}
阅读全文
0 0
- 杭电acm 4142Triangle(小学生题,判断三角形)
- 杭电ACM 2039 三角形
- 杭电ACM 2039 三角形
- 杭电ACM 2039: 三角形
- 杭电acm 2091 空心三角形
- 杭电ACM 2091:空心三角形
- ACM判断三角形(多组输入)
- ACM 三角形判断
- 109.Triangle-数字三角形(容易题)
- 杭电acm2091 hdu-acm-2091空心三角形解题报告
- 倒三角形(triangle)
- 倒三角形(triangle)
- 倒三角形(triangle)
- 倒三角形(triangle)
- 倒三角形(triangle)
- CF 6A Triangle (判断三角形)
- 【杭电-oj】-2393-Higher Math(判断是否为三角形)
- 杭电acm2039:给三边长判断能不能构成三角形
- codefores 834B The Festive Evening
- angular的post请求,springmvc后台接收不到参数的解决方案
- TCP Keepalive
- 1972-斐波那契数列
- JAVA运用dos命令强制删除文件夹
- 杭电acm 4142Triangle(小学生题,判断三角形)
- Red Hat Enterprise Linu 7 3.1.13关机命令
- GCD and LCM
- Weblogic部署maven web项目
- shiro+redis实现session共享<2>
- Windows下的Dump文件
- Android系统级服务:DevicePolicyManager
- 总结问题解决
- HDU