Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Ex13_GameOfNumbers
- {
- using System;
- public class Program
- {
- 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 first = 0;
- int second = 0;
- int sum = 0;
- int counter = 0;
- for (int i = M; i >= N; i--)
- {
- for (int j = M; j >= N; j--)
- {
- counter++;
- first = i;
- second = j;
- sum = i + j;
- if (sum == magic)
- {
- break;
- }
- }
- if (sum == magic)
- {
- break;
- }
- }
- if (sum == magic)
- {
- Console.WriteLine($"Number found! {first} + {second} = {magic}");
- }
- else
- {
- Console.WriteLine($"{counter} combinations - neither equals {magic}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment