HUST 1555 数学作业

参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html

1555 - A Math Homework

时间限制:1秒 内存限制:128兆

题目描述

  QKL is a poor and busy guy, and he was not good at math. 
  Last day, his teacher assigned a homework: Give you 3 segments with positive length, can you use these segments to make a triangle? If can, what is the type of the triangle? Acute triangle, right triangle or obtuse triangle? Pay attention that vertices of triangle must be vertices of two segments.
  QKL is afraid of any type of math problems, so he turns to you for help. Can you help him?

输入

  Several test cases, one line per case.
  In case consists of three positive integers: a, b, c, indicating the lengths of 3 segments.
  0 < a, b, c <= 10000

输出

  In each test case, you just print one line of result.
  If you can't make a triangle by using these segments, print "FAIL TO MAKE!"(quote for clarify).
  If you can make an acute triangle, print "Acute"(quote for clarify).
  If you can make a right triangle, print "Right"(quote for clarify).
  If you can make an obtuse triangle, print "Obtuse"(quote for clarify).

样例输入

1 2 3
2 3 4
3 4 5
4 5 6

样例输出

FAIL TO MAKE!
Obtuse
Right
Acute

提示

  You can use this form of code to deal with several test cases.
  while (scanf("%d%d%d", &a, &b, &c) != EOF)
  {
    //Your codes here. 
  }

解法:

 

 1 #include <stdio.h>
 2 int main(){
 3     int a,b,c;
 4     while(scanf("%d%d%d",&a,&b,&c)!=EOF){
 5         if(a+b<=c||a+c<=b||b+c<=a)
 6             printf("FAIL TO MAKE!");
 7         else{
 8             if(a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0)
 9                 printf("Right\n");
10             else if(a*a+b*b-c*c<0||a*a+c*c-b*b<0||b*b+c*c-a*a<00)
11                 printf("Obtuse\n");
12             else printf("Acute\n");
13         } 
14     }
15     return 0;
16 }

 

 

 

 
 


 
posted @ 2019-02-02 14:50  cruelty_angel  阅读(254)  评论(0编辑  收藏  举报