Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _13._Game_of_Numbers
- {
- class GameOfNumbers
- {
- static void Main(string[] args)
- {
- //Write a program, which finds all possible combinations in the interval between two numbers. The program should also find
- //the last combination, in which a number’s digits are equal to a given magical number.
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int magicNum = int.Parse(Console.ReadLine());
- int sumDigits = 0;
- int count = 0;
- for (int i = m; i >= n; i--)
- {
- for (int k = m; k >= n; k--)
- {
- count++;
- if (i + k == magicNum)
- {
- Console.WriteLine($"Number found! {i} + {k} = {magicNum}");
- return;
- }
- }
- }
- Console.WriteLine($"{count} combinations - neither equals {magicNum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment