Advertisement
Niicksana

Сбор или Произведение

Dec 15th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _6.Сбор_или_Произведение
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 25 June 2017
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             bool found = false;
  17.  
  18.             for (int a = 1; a <= 30; a++)
  19.             {
  20.                 for (int b = 1; b <= 30; b++)
  21.                 {
  22.                     for (int c = 1; c <= 30; c++)
  23.                     {
  24.                         if (a < b && b < c  )
  25.                         {
  26.                             if (a + b + c == n)
  27.                             {
  28.                                 found = true;
  29.                                 Console.WriteLine($"{a} + {b} + {c} = {n}");
  30.                             }
  31.                         }
  32.  
  33.                         else if (a > b && b > c)
  34.                         {
  35.                             if (a * b * c == n)
  36.                             {
  37.                                 found = true;
  38.                                 Console.WriteLine($"{a} * {b} * {c} = {n}");
  39.                             }
  40.                         }
  41.                     }
  42.                 }
  43.             }
  44.  
  45.             if (found == false)
  46.             {
  47.                 Console.WriteLine("No!");
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement