HDU 2393 Higher Math
2016-01-18 20:17
232 查看
Higher Math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2972 Accepted Submission(s): 1580
[align=left]Problem Description[/align]
You are building a house. You’d prefer if all the walls have a precise right angle relative to the ground, but you have no device to measure angles. A friend says he has a great idea how you could ensure
that all walls are upright: All you need to do is step away a few feet from the wall, measure how far away you are from the wall, measure the height of the wall, and the distance from the upper edge of the wall to where you stand. You friend tells you to do
these measurements for all walls, then he’ll tell you how to proceed. Sadly, just as you are done, a timber falls on your friend, and an ambulance brings him to the hospital. This is too bad, because now you have to figure out what to do with your measurements
yourself.
Given the three sides of a triangle, determine if the triangle is a right triangle, i.e. if one of the triangle’s angles is 90 degrees.
[align=left]Input[/align]
The inputs start with a line containing a single integer n. Each of the n following lines contains one test case. Each test case consists of three integers 1 <= a, b, c <= 40000 separated by a space. The
three integers are the lengths of the sides of a triangle.
[align=left]Output[/align]
The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1. After that, output a single line containing either the string “yes” or
the string “no”, depending on if the triangle in this test case has a right angle. Terminate each test case with an empty line.
[align=left]Sample Input[/align]
2
36 77 85
40 55 69
[align=left]Sample Output[/align]
Scenario #1:
yes
Scenario #2:
no
分析:该题要判断三边组成的三角形是否为直角三角形。格式要求每个示例后面有一个空行
代码如下:
#include <stdio.h>
void swap(int &a,int &b,int &c)
{
int temp;
if(a>b)
{
temp=a;
a=b;
b=temp;
}
if(a>c)
{
temp=c;
c=a;
a=temp;
}
if(b>c)
{
temp=b;
b=c;
c=temp;
}
}
int main()
{
int n;
int i,j;
int a,b,c;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d %d",&a,&b,&c);
printf("Scenario #%d:\n",i);
swap(a,b,c);
if(a*a+b*b==c*c)
printf("yes\n");
else
printf("no\n");
putchar('\n');
}
return 0;
}
相关文章推荐
- 40-打印直角三角形
- 直角三角形 (Standard IO)
- [F 4000 DU1669] 直角三角形
- java基础--for循环嵌套打印输出直角三角形
- 打印各种图案
- iOS 本地数据持久化 中UserDefault的使用
- Unity学习笔记之UGUI模块RectTransform的变换推导
- 数据库的同步操作
- 在Android中显示gif图片
- 应用服务器简介
- 自动匹配输入和记住密码
- iOS 简易无限滚动的图片轮播器 Demo事例
- 设计模式之禅之设计模式-责任链模式
- 关于Android studio混淆遇到的问题
- Java基础:多线程之ReadWriteLock、Condition、Semaphore
- web.xml文件的作用
- 使用Python找出历史上5星好评数最多的50部电影,基于MovieLens20M数据集
- 逆波兰表达式(中序表达式转后序表式式)
- \\ip\c$找不到网络名(或网络路径)
- Reading With Purpose: A grand experiment