SHARE
TWEET

Game of Numbers

simeon3000 May 29th, 2017 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             int N = int.Parse(Console.ReadLine());
  2.             int M = int.Parse(Console.ReadLine());
  3.             int magic = int.Parse(Console.ReadLine());
  4.  
  5.             int iMagic = 0;
  6.             int jMagic = 0;
  7.             int counter = 0;
  8.  
  9.             for (int i = N; i <= M; i++)
  10.             {
  11.                 for (int j = N; j <= M; j++)
  12.                 {
  13.                     if (i + j == magic)
  14.                     {
  15.                         iMagic = i; jMagic = j;                      
  16.                     }
  17.                     counter++;
  18.                 }
  19.             }
  20.  
  21.             if (iMagic !=0)
  22.             {
  23.                 Console.WriteLine($"Number found! {iMagic} + {jMagic} = {magic}");
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine($"{counter} combinations - neither equals {magic}");
  28.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top