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 Two_Numbers_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- int end = int.Parse(Console.ReadLine());
- int start = int.Parse(Console.ReadLine());
- int magicNumber = int.Parse(Console.ReadLine());
- int combinationCounter = 0;
- bool isNumberMagic = false;
- for (int i = end; i >= start; i--)
- {
- if(isNumberMagic==true)
- {
- break;
- }
- for (int j = end; j >= start; j--)
- {
- combinationCounter++;
- if (i + j == magicNumber)
- {
- Console.WriteLine("Combination N:{0} ({1} + {2} = {3})", combinationCounter, i, j, magicNumber);
- isNumberMagic = true;
- break;
- }
- }
- }
- if (isNumberMagic==false)
- {
- Console.WriteLine("{0} combinations - neither equals {1}", combinationCounter, magicNumber);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment