Created
May 7, 2015 15:36
-
-
Save EBojilova/2934d86c6f2cb9691565 to your computer and use it in GitHub Desktop.
09.Pythagorean Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class PythagoreanNumbers | |
{ | |
static void Main(string[] args) | |
{ | |
int n = int.Parse(Console.ReadLine()); | |
int[] nums=new int[n]; | |
bool pitagoreanEquation = false; | |
for (int i = 0; i < n; i++) | |
{ | |
nums[i] = int.Parse(Console.ReadLine()); | |
} | |
for (int p1 = 0; p1 < n; p1++) | |
{ | |
for (int p2 = 0; p2 < n; p2++) | |
{ | |
for (int p3 = 0; p3 < n; p3++) | |
{ | |
if ((nums[p1]*nums[p1] +nums[p2]*nums[p2])==nums[p3]*nums[p3] && nums[p1]<=nums[p2]) | |
{ | |
Console.WriteLine("{0}*{0} + {1}*{1} = {2}*{2}", nums[p1], nums[p2], nums[p3]); | |
pitagoreanEquation = true; | |
} | |
} | |
} | |
} | |
if (!pitagoreanEquation) | |
{ | |
Console.WriteLine("No"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment