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