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