SHARE
TWEET

Untitled

a guest May 27th, 2017 183 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. namespace _13.Game_of_Numbers
  3. {
  4.     class Program
  5.     {
  6.         static void Main()
  7.         {
  8.             int matchCounter = 0;
  9.             int sum = 0;
  10.             int counter = 0;
  11.             var n = int.Parse(Console.ReadLine());
  12.             var m = int.Parse(Console.ReadLine());
  13.             var magicNumber = int.Parse(Console.ReadLine());
  14.             for (int i = n; i <= m; i++)
  15.             {
  16.                 for (int j = m; j >= n; j--)
  17.                 {
  18.                     sum = i + j;
  19.                     counter++;
  20.                     if (sum == magicNumber)
  21.                     {
  22.                         Console.WriteLine("Number found! {0} + {1} = {2}", i, j, magicNumber);
  23.                         matchCounter++;
  24.                     }
  25.                 }
  26.             }
  27.             if (matchCounter == 0)
  28.             {
  29.                 Console.WriteLine("{0} combinations - neither equals {1}", counter, magicNumber);
  30.             }
  31.         }
  32.     }
  33. }
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