Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace GameOfNums
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int magic = int.Parse(Console.ReadLine());
- int counter = 0;
- int combination = 0;
- for (int i = n; i <= m; i++)
- {
- for (int j = n; j <= m; j++)
- {
- if (j+i==magic)
- {
- Console.WriteLine($"Number found! {j} + {i} = {magic}");
- combination++;break;
- }
- counter++;
- }
- if (combination>0)
- {
- break;
- }
- }
- if (combination==0)
- {
- Console.WriteLine($"{counter} combinations - neither equals {magic}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment