Advertisement
IvanBorisovG

GameOfNumbers

Jan 30th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace GameOfNumbers
  4. {
  5.     class GameOfNumbers
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var n = int.Parse(Console.ReadLine());
  10.             var m = int.Parse(Console.ReadLine());
  11.             var magicalNumber = int.Parse(Console.ReadLine());
  12.             var sum = 0;
  13.             var combinations = 0;
  14.             for (int i = n; i <= m; i++)
  15.             {
  16.                 for (int j = n; j <= m; j++)
  17.                 {
  18.                     combinations++;
  19.                     if (i + j == magicalNumber)
  20.                     {
  21.                         Console.WriteLine($"Number found! {j} + {i} = {magicalNumber}");
  22.                         return;
  23.                     }
  24.                 }
  25.             }
  26.             Console.WriteLine($"{combinations} combinations - neither equals {magicalNumber}");
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement