Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _13_GameOfNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int N = int.Parse(Console.ReadLine());
- int M = int.Parse(Console.ReadLine());
- int Magic = int.Parse(Console.ReadLine());
- int comb = 0;
- int sum = 0;
- int last = 0;
- int first = 0;
- int second = 0;
- for (int i = N; i <= M; i++)
- {
- for (int j = N; j <= M; j++)
- {
- sum = i + j;
- comb++;
- if (sum == Magic)
- {
- last = sum;
- first = i;
- second = j;
- }
- }
- }
- if (last == 0)
- {
- Console.WriteLine($"{comb} combinations - neither equals {Magic}");
- }
- else
- {
- Console.WriteLine($"Number found! {first} + {second} = {Magic}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement