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 firstNum = int.Parse(Console.ReadLine());
- int secondNum = int.Parse(Console.ReadLine());
- int magicNum = int.Parse(Console.ReadLine());
- int combinations = 0;
- bool isFound = false;
- for (int i = firstNum; i <= secondNum; i++)
- {
- for (int j = firstNum; j <= secondNum; j++)
- {
- combinations++;
- if (i + j == magicNum)
- {
- Console.WriteLine($"Combination N:{ combinations} ({ i} + { j} = { magicNum})");
- isFound = true;
- break;
- }
- }
- if (isFound) {
- break;
- }
- }
- if (isFound == false)
- {
- Console.WriteLine($"{ combinations} combinations - neither equals { magicNum}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment