Advertisement
alidzhikov

PythagoreanNumbers

May 7th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. class PythagoreanNumbers
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.  
  8.         int[] numbers = new int[n];
  9.         for (int i = 0; i < n; i++)
  10.         {
  11.             numbers[i] = int.Parse(Console.ReadLine());
  12.         }
  13.  
  14.         bool matchFound = false;
  15.         for (int indexOne = 0; indexOne < n; indexOne++)
  16.         {
  17.             for (int indexTwo = 0; indexTwo < n; indexTwo++)
  18.             {
  19.                 for (int indexThree = 0; indexThree < n; indexThree++)
  20.                 {
  21.                     int a = numbers[indexOne];
  22.                     int b = numbers[indexTwo];
  23.                     int c = numbers[indexThree];
  24.  
  25.                     if (a <= b && (a * a) + (b * b) == (c * c))
  26.                     {
  27.                         Console.WriteLine("{0}*{0} + {1}*{1} = {2}*{2}", a, b, c);
  28.                         matchFound = true;
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.         if (!matchFound)
  34.         {
  35.             Console.WriteLine("No");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement