Advertisement
martinvalchev

Game_of_Numbers

Jan 30th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Game_of_Numbers
  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 magical = int.Parse(Console.ReadLine());
  12.             int counter = 0;
  13.  
  14.             for (int i = m; i >=n ; i--)
  15.             {
  16.                 for (int j = m; j >=n; j--)
  17.                 {
  18.                     if (i + j == magical)
  19.                     {
  20.                         Console.WriteLine($"Number found! {i} + {j} = {magical}");
  21.                         return;
  22.                     }
  23.                     counter++;
  24.                 }
  25.                
  26.             }
  27.             Console.WriteLine($"{counter} combinations - neither equals {magical}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement