Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SumOfTwoNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int x = int.Parse(Console.ReadLine());
- int y = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int i = 0;
- int o = 0;
- bool magic = false;
- int counter = 0;
- for (i = x; i <= y; i++)
- {
- for (o = x; o <= y; o++)
- {
- counter++;
- if (i + o == m)
- {
- magic = true;
- break;
- }
- }
- if (magic == true)
- {
- break;
- }
- }
- if (magic == false)
- {
- Console.WriteLine($"{counter} combinations - neither equals {m}");
- }
- else
- {
- Console.WriteLine($"Combination N:{counter} ({i} + {o} = {m})");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment