Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int firstNum = int.Parse(Console.ReadLine());
- int secondNum = int.Parse(Console.ReadLine());
- int magicNum = int.Parse(Console.ReadLine());
- int counter = 0;
- int sum = 0;
- int secondCounter = 0;
- for (int i = secondNum; i >= firstNum; i--)
- {
- for (int j = secondNum; j >= firstNum; j--)
- {
- counter++;
- sum = i + j;
- if (sum == magicNum)
- {
- Console.WriteLine("Number found! {0} + {1} = {2}", i, j, magicNum);
- secondCounter++;
- return;
- }
- }
- }
- if (secondCounter == 0)
- {
- Console.WriteLine("{0} combinations - neither equals {1}", counter, magicNum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement