Fork me on GitHub

题目1048:判断三角形类型(直角、锐角、钝角)

题目链接:http://ac.jobdu.com/problem.php?pid=1048

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
//  1048 判断三角形类型.cpp
//  Jobdu
//
//  Created by PengFei_Zheng on 02/05/2017.
//  Copyright © 2017 PengFei_Zheng. All rights reserved.
//
 
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <cmath>
//#define debug
using namespace std;
 
int a, b, c;
 
int main(){
#ifdef debug
    freopen("/Users/pengfei_zheng/Desktop/input.txt", "r", stdin);
#endif
    while(scanf("%d%d%d",&a,&b,&c)!=EOF){
        int maxNum = max(a,max(b,c));
        int minNum = min(a,min(b,c));
        int midNum = a + b + c - maxNum - minNum;
        int tmp1 = minNum * minNum + midNum * midNum;
        int tmp2 = maxNum * maxNum;
        if(tmp1 == tmp2){
            printf("直角三角形\n");
        }
        else if(tmp1 < tmp2){
            printf("钝角三角形\n");
        }
        else if(tmp1 > tmp2){
            printf("锐角三角形\n");
        }
    }
    return 0;
}
/**************************************************************
    Problem: 1048
    User: zpfbuaa
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1520 kb
****************************************************************/

 

posted @ 2017-05-02 19:05  伊甸一点  阅读(991)  评论(0编辑  收藏  举报