SHARE
TWEET

Untitled

a guest May 27th, 2017 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace GameOfNumbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.             int magicalNumbers = int.Parse(Console.ReadLine());
  12.             int combinations = 0, firstNumber = 0, secondNumer = 0;
  13.             for (firstNumber = n; firstNumber <= m; firstNumber++)
  14.             {
  15.                 for (secondNumer = n; secondNumer <= m; secondNumer++)
  16.                 {
  17.                     combinations++;
  18.  
  19.                     if (firstNumber + secondNumer == magicalNumbers && firstNumber > secondNumer)
  20.                     {
  21.                         Console.WriteLine($"Number found! {firstNumber} + {secondNumer} = {magicalNumbers}");
  22.                         return;
  23.                        
  24.                        
  25.                     }
  26.                    
  27.                     if (firstNumber + secondNumer != magicalNumbers && (firstNumber == m && secondNumer == m))
  28.                     {
  29.  
  30.                         Console.WriteLine($"{combinations} combinations - neither equals {magicalNumbers}");
  31.                         break;
  32.                     }
  33.                 }
  34.             }
  35.         }
  36.     }
  37. }
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