九度oj 1048

来源:互联网 发布:海关数据工作 编辑:程序博客网 时间:2024/06/06 15:44
题目描述:

给定三角形的三条边,a,b,c。判断该三角形类型。

输入:

测试数据有多组,每组输入三角形的三条边。

输出:

对于每组输入,输出直角三角形、锐角三角形、或是钝角三角形。

样例输入:
3 4 5
样例输出:
直角三角形
来源:

2009年哈尔滨工业大学计算机研究生机试真题

#include<iostream>#include<math.h>#include<algorithm>using namespace std;int main(){    int a,b,c;    int str[4];    while(cin>>a>>b>>c)    {                                               str[0]=a;                       str[1]=b;                       str[2]=c;                       sort(str,str+3);                       double num=(str[0]*str[0]+str[1]*str[1]-str[2]*str[2]);                                                                     if(num<0)                       {                                 cout<<"钝角三角形"<<endl;                                 }                                 else if(num>0)                                 {                                      cout<<"锐角三角形"<<endl;                                      }                                      else                                      cout<<"直角三角形"<<endl;                                      }                                      } 


0 0