Advertisement
Guest User

Problem 9 works

a guest
Nov 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. /*
  2.  *  C# Program to Find a Number using Pythagoras Theorem
  3.  */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Linq;
  8. using System.Text;
  9. class Program
  10. {
  11.     static void Main(string[] args)
  12.     {
  13.  
  14.         double a, b, c;
  15.         bool answer = false;
  16.         Stopwatch sw = new Stopwatch();
  17.         sw.Start();
  18.         for (int n = 0;answer ==false && n < 1000 ; n++)
  19.         {
  20.             a = n;
  21.             Console.WriteLine(a);
  22.             for (int i = 0; i < n; i++)
  23.             {
  24.                
  25.                 b = a - i;
  26.                
  27.             for (int x = 0; x < b; x++)
  28.                 {
  29.                     c = b - x;
  30.                     if (a == Math.Sqrt(b * b + c * c) && a + b + c == 1000)
  31.                     {
  32.                         double d = (a * b * c);
  33.                         Console.WriteLine("Time to calculate in milliseconds : {0}", sw.ElapsedMilliseconds);
  34.                         Console.WriteLine(d);
  35.                         Console.ReadLine();
  36.  
  37.                     }
  38.                    
  39.                 }
  40.             }
  41.         }
  42.         Console.WriteLine("This is a the end");
  43.         Console.ReadLine();
  44.     }
  45.        
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement