Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace P13GameOfNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int magicNum = int.Parse(Console.ReadLine());
- int combinations = 0;
- var lastComb = string.Empty;
- for (int k = n; k <= m; k++)
- {
- for (int j = n; j <= m; j++)
- {
- combinations++;
- if (k + j== magicNum && k > j)
- {
- lastComb = $"Number found! {k} + {j} = {magicNum}";
- }
- }
- }
- if (lastComb == string.Empty)
- {
- Console.WriteLine($"{combinations} combinations - neither equals {magicNum}");
- }
- else
- {
- Console.WriteLine(lastComb);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement