def dist2(x1, y1, x2, y2): # 두 점 사이 거리의 제곱을 돌려준다. 제곱근을 구하지 않으므로 늘 정수다 dx = x1 - x2 dy = y1 - y2 return dx * dx + dy * dyn = int(input())for _ in range(n): x1, y1, x2, y2, x3, y3 = map(int, input().split()) # 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 a = dist2(x1, y1, x2, y2) b = dist2(x2, y2, x3, y3) c = dist2(x3, y3, x1, y1) big = max(a, b, c) rest = a + b + c - big # 나머지 두 변의 제곱의 합 if rest == big: print("直角") elif rest > big: print("锐角") else: print("钝角")
JavaScriptmain.js · 23 行
// 두 점 사이 거리의 제곱을 돌려준다. 제곱근을 구하지 않으므로 늘 정수다function dist2(x1, y1, x2, y2) { const dx = x1 - x2; const dy = y1 - y2; return dx * dx + dy * dy;}const lines = require("fs").readFileSync(0, "utf8").split("\n");const n = Number(lines[0]);const out = [];for (let i = 1; i <= n; i++) { const [x1, y1, x2, y2, x3, y3] = lines[i].trim().split(/\s+/).map(Number); // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 const a = dist2(x1, y1, x2, y2); const b = dist2(x2, y2, x3, y3); const c = dist2(x3, y3, x1, y1); const big = Math.max(a, b, c); const rest = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest === big) out.push("直角"); else if (rest > big) out.push("锐角"); else out.push("钝角");}console.log(out.join("\n"));
TypeScriptmain.ts · 25 行
import { readFileSync } from "node:fs";// 두 점 사이 거리의 제곱을 돌려준다. 괄호 뒤의 `: number`가 돌려주는 값의 타입이다function dist2(x1: number, y1: number, x2: number, y2: number): number { const dx = x1 - x2; const dy = y1 - y2; return dx * dx + dy * dy;}const lines: string[] = readFileSync(0, "utf8").split("\n");const n: number = Number(lines[0]);const out: string[] = [];for (let i = 1; i <= n; i++) { const [x1, y1, x2, y2, x3, y3]: number[] = lines[i].trim().split(/\s+/).map(Number); // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 const a: number = dist2(x1, y1, x2, y2); const b: number = dist2(x2, y2, x3, y3); const c: number = dist2(x3, y3, x1, y1); const big: number = Math.max(a, b, c); const rest: number = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest === big) out.push("直角"); else if (rest > big) out.push("锐角"); else out.push("钝角");}console.log(out.join("\n"));
JavaMain.java · 35 行
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class Main { // 두 점 사이 거리의 제곱을 돌려준다. 이름 앞의 int가 돌려주는 값의 타입이다 static int dist2(int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = y1 - y2; return dx * dx + dy * dy; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine().trim()); StringBuilder out = new StringBuilder(); for (int i = 0; i < n; i++) { StringTokenizer st = new StringTokenizer(br.readLine()); int x1 = Integer.parseInt(st.nextToken()), y1 = Integer.parseInt(st.nextToken()); int x2 = Integer.parseInt(st.nextToken()), y2 = Integer.parseInt(st.nextToken()); int x3 = Integer.parseInt(st.nextToken()), y3 = Integer.parseInt(st.nextToken()); // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 int a = dist2(x1, y1, x2, y2); int b = dist2(x2, y2, x3, y3); int c = dist2(x3, y3, x1, y1); int big = Math.max(a, Math.max(b, c)); int rest = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest == big) out.append("直角\n"); else if (rest > big) out.append("锐角\n"); else out.append("钝角\n"); } System.out.print(out); }}
C#Main.cs · 36 行
using System;using System.Text;class Program{ // 두 점 사이 거리의 제곱을 돌려준다. 이름 앞의 int가 돌려주는 값의 타입이다 static int Dist2(int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = y1 - y2; return dx * dx + dy * dy; } static void Main() { int n = int.Parse(Console.ReadLine()); var sb = new StringBuilder(); for (int i = 0; i < n; i++) { string[] p = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); int x1 = int.Parse(p[0]), y1 = int.Parse(p[1]); int x2 = int.Parse(p[2]), y2 = int.Parse(p[3]); int x3 = int.Parse(p[4]), y3 = int.Parse(p[5]); // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 int a = Dist2(x1, y1, x2, y2); int b = Dist2(x2, y2, x3, y3); int c = Dist2(x3, y3, x1, y1); int big = Math.Max(a, Math.Max(b, c)); int rest = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest == big) sb.Append("直角\n"); else if (rest > big) sb.Append("锐角\n"); else sb.Append("钝角\n"); } Console.Write(sb); }}
C++main.cpp · 29 行
#include <algorithm>#include <iostream>// 두 점 사이 거리의 제곱을 돌려준다. 이름 앞의 int가 돌려주는 값의 타입이다int dist2(int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = y1 - y2; return dx * dx + dy * dy;}int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; for (int i = 0; i < n; i++) { int x1, y1, x2, y2, x3, y3; std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 int a = dist2(x1, y1, x2, y2); int b = dist2(x2, y2, x3, y3); int c = dist2(x3, y3, x1, y1); int big = std::max({a, b, c}); int rest = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest == big) std::cout << "直角\n"; else if (rest > big) std::cout << "锐角\n"; else std::cout << "钝角\n"; }}
Cmain.c · 29 行
#include <stdio.h>// 두 점 사이 거리의 제곱을 돌려준다. 이름 앞의 int가 돌려주는 값의 타입이다int dist2(int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = y1 - y2; return dx * dx + dy * dy; // C에는 거듭제곱 연산자가 없다. ^는 XOR이다}int main(void) { int n; if (scanf("%d", &n) != 1) return 0; for (int i = 0; i < n; i++) { int x1, y1, x2, y2, x3, y3; if (scanf("%d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3) != 6) return 0; // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 int a = dist2(x1, y1, x2, y2); int b = dist2(x2, y2, x3, y3); int c = dist2(x3, y3, x1, y1); int big = a; if (b > big) big = b; if (c > big) big = c; int rest = a + b + c - big; // 나머지 두 변의 제곱의 합 if (rest == big) puts("直角"); else if (rest > big) puts("锐角"); else puts("钝角"); } return 0;}
Craykonmain.cray · 31 行
// 두 점 사이 거리의 제곱을 돌려준다. 제곱근을 구하지 않으므로 늘 정수다거리제곱(x1, y1, x2, y2){ dx = x1 - x2; dy = y1 - y2; 返回 dx * dx + dy * dy;}n = 控制台.读行().转数字();循环 (i = 0; i < n; i++){ p = 控制台.读数字(); // 같은 함수를 세 번 부른다: 변마다 두 점만 바뀐다 a = 거리제곱(p[0], p[1], p[2], p[3]); b = 거리제곱(p[2], p[3], p[4], p[5]); c = 거리제곱(p[4], p[5], p[0], p[1]); big = 数学.较大值(a, 数学.较大值(b, c)); rest = a + b + c - big; // 나머지 두 변의 제곱의 합 如果 (rest == big) { 控制台.输出("直角"); } 否则 如果 (rest > big) { 控制台.输出("锐角"); } 否则 { 控制台.输出("钝角"); }}