Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package PythagoreanNumbers;
- import java.util.Scanner;
- /**
- *
- * @author pc6
- */
- public class PytagoreanNumbers {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- int[] arr = new int[n];
- for (int i = 0; i < n; i++) {
- arr[i] = input.nextInt();
- }
- // for (int i = 0; i < arr.length; i++) {
- // System.out.print(arr[i] + " ");
- // }
- // System.out.println();
- boolean isPit = false;
- for (int a = 0; a < arr.length; a++) {
- int aa = arr[a] * arr[a];
- for (int b = 0; b < arr.length; b++) {
- int bb = arr[b] * arr[b];
- for (int c = 0; c < arr.length; c++) {
- int cc = arr[c] * arr[c];
- if (aa + bb == cc) {
- if (aa + bb == cc) {
- System.out.println(arr[a] + "*" + arr[a] + " + " + arr[b] + "*" + arr[b] + " = " + arr[c] + "*" + arr[c]);
- isPit = true;
- }
- }
- }
- }
- }
- if (!isPit) {
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement