zoukankan      html  css  js  c++  java
  • LightOJ 1053

    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.

    Input
    Input starts with an integer T (≤ 200), denoting the number of test cases.

    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.

    就是判断三角形三边是否是直角三角形

    #include<bits/stdc++.h>
    using namespace std;
    
    void solve(int cases)
    {
        vector<long long> vec(3);
        cin >> vec[0] >> vec[1] >> vec[2];
        sort(vec.begin(), vec.end());
        cout << "Case " << cases << ": ";
        if(vec[0] * vec[0] + vec[1] * vec[1] == vec[2] * vec[2])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    
    int main()
    {
        ios::sync_with_stdio(false);
        //freopen("out.txt", "w", stdout);
        int t;
        cin >> t;
        for(int i=1; i<=t; ++ i)
            solve(i);
        return 0;
    }
    
    
  • 相关阅读:
    mybatis mybatis-generator 代码自动生成工具使用
    spring初步
    spring基于xml和注解配置事务
    强软弱虚四大引用
    线程通信的几种实现方式
    java8新特性之方法引用和构造器引用
    JAVA四大内置函数
    JAVA四大内置函数
    JSR303的使用
    设计模式之建造者模式
  • 原文地址:https://www.cnblogs.com/aiterator/p/6849593.html
Copyright © 2011-2022 走看看