Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Купа
- {
- class Program
- {
- static void Main(string[] args)
- {
- int startNumber = int.Parse(Console.ReadLine());
- bool valid = false;
- for (int a = 1; a <= 30; a++)
- {
- for (int b = 1; b <= 30; b++)
- {
- for (int c = 1; c <= 30; c++)
- {
- if (a + b + c == startNumber)
- {
- if (a < b && b < c && a < c)
- {
- Console.WriteLine($"{a} + {b} + {c} = {startNumber}");
- valid = true;
- }
- }
- if (a * b * c == startNumber)
- {
- if (a > b && b > c && a > c)
- {
- Console.WriteLine($"{a} * {b} * {c} = {startNumber}");
- valid = true;
- }
- }
- }
- }
- }
- if (!valid)
- {
- Console.WriteLine("No!");
- }
- }
- }
- }
- // Сбор или Произведение
- // 12
- // 1 + 2 + 9 = 12
- // 1 + 3 + 8 = 12
- // 1 + 4 + 7 = 12
- // 1 + 5 + 6 = 12
- // 2 + 3 + 7 = 12
- // 2 + 4 + 6 = 12
- // 3 + 4 + 5 = 12
- // 4 * 3 * 1 = 12
- // 6 * 2 * 1 = 12
Advertisement
Add Comment
Please, Sign In to add comment