Seal_of_approval

Pr4R6ex16

Sep 11th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace test
  4. {
  5.     class Program
  6.     {
  7.         static int nod (int a, int b)
  8.         {
  9.             while (a != b ) {
  10.                 if (a > b)
  11.                     a -= b;
  12.                 else
  13.                     b -= a;
  14.             }
  15.             int nod = a;
  16.             return nod;
  17.         }
  18.  
  19.         static void Main ()
  20.         {
  21.             Console.WriteLine ("Enter a & b ");
  22.  
  23.             int a = int.Parse (Console.ReadLine ());
  24.             int b = int.Parse (Console.ReadLine ());
  25.             int x = a * a + b * b;
  26.             int y = a * b;
  27.             Console.WriteLine("{0}/{1}", (double)x/nod(x,y), (double)y/nod(x,y));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment