Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 정렬
- Unreal Engine 5
- c++
- 트리
- 수학
- BFS
- 유니온 파인드
- 백준
- 시뮬레이션
- ue5
- 스택
- VR
- 재귀
- 유니티
- 문자열
- 알고리즘
- Team Fortress 2
- 투 포인터
- 구현
- 자료구조
- 그래프
- 브루트포스
- XR Interaction Toolkit
- 백트래킹
- 다익스트라
- 다이나믹 프로그래밍
- 그리디 알고리즘
- 우선순위 큐
- DFS
- 누적 합
Archives
- Today
- Total
1일1알
백준 4153번 직각삼각형 C++ 본문
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
int a, b, c;
int arr[3];
while (1) {
cin >> a >> b >> c;
//while문 종료
if (a == 0 && b == 0 && c == 0) break;
arr[0] = a;
arr[1] = b;
arr[2] = c;
//오름차순 정렬
sort(arr, arr + 3);
if (arr[0] * arr[0] + arr[1] * arr[1] == arr[2] * arr[2]) {
cout << "right" << endl;
}
else {
cout << "wrong" << endl;
}
}
}
세 수를 입력받아서 오름차순으로 정렬한 뒤 arr[0]^2 + arr[1]^2 =arr[2]^2 를 만족한다면 직각삼각형, 아니면 직각삼각형이 아니다.
'알고리즘' 카테고리의 다른 글
백준 16953번 A->B (C++) (0) | 2021.10.19 |
---|---|
백준 11660번 구간 합 구하기 5 C++ (0) | 2021.10.18 |
백준 11725번 트리의 부모 찾기 C++ (0) | 2021.10.17 |
백준 9465번 스티커 C++ (0) | 2021.10.16 |
백준 1085번 직사각형에서 탈출 C++ (0) | 2021.10.15 |