Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1
- using System;
- 2
- 3
- namespace GameOfNums
- 4
- {
- 5
- class MainClass
- 6
- {
- 7
- public static void Main(string[] args)
- 8
- {
- 9
- int n = int.Parse(Console.ReadLine());
- 10
- int m = int.Parse(Console.ReadLine());
- 11
- int magic = int.Parse(Console.ReadLine());
- 12
- 13
- int counter = 0;
- 14
- int combination = 0;
- 15
- 16
- for (int i = n; i <= m; i++)
- 17
- {
- 18
- for (int j = n; j <= m; j++)
- 19
- {
- 20
- if (j+i==magic)
- 21
- {
- 22
- Console.WriteLine($"Number found! {j} + {i} = {magic}");
- 23
- combination++;break;
- 24
- }
- 25
- counter++;
- 26
- }
- 27
- if (combination>0)
- 28
- {
- 29
- break;
- 30
- }
- 31
- }
- 32
- if (combination==0)
- 33
- {
- 34
- Console.WriteLine($"{counter} combinations - neither equals {magic}");
- 35
- }
- 36
- 37
- 38
- }
- 39
- }
- 40
- }
- 41
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement