Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._Exam___Math_Puzzle
- {
- class Program
- {
- static void Main(string[] args)
- {
- int keyNumber = int.Parse(Console.ReadLine());
- int combinationNumber = 0;
- for (int a = 1; a <= 30; a++)
- {
- for (int b = 1; b <= 30; b++)
- {
- for (int c = 0; c <= 30; c++)
- {
- if (a + b + c == keyNumber)
- {
- if (a < b && b < c)
- {
- Console.WriteLine($"{a} + {b} + {c} = {a + b + c}");
- combinationNumber++;
- }
- }
- else if (a * b * c == keyNumber)
- {
- if (c < b && b < a)
- {
- Console.WriteLine($"{a} * {b} * {c} = {a * b * c}");
- combinationNumber++;
- }
- }
- }
- }
- }
- if (combinationNumber == 0)
- {
- Console.WriteLine("No!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement