MiroslavKisov

Sum_Or_Multiplication

Aug 11th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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 Sum_Or__Multiplication
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             bool isFound = false;
  14.             int controlNumber = int.Parse(Console.ReadLine());
  15.             for (int i = 1; i <= 30; i++)
  16.             {
  17.                 for (int j = 1; j <= 30; j++)
  18.                 {
  19.                     for (int k = 1; k <= 30; k++)
  20.                     {
  21.                         if (i < j && j < k && i + j + k == controlNumber)
  22.                         {
  23.                             isFound = true;
  24.                             Console.WriteLine("{0} + {1} + {2} = {3}", i, j, k, controlNumber);
  25.                         }
  26.                         if (i > j && j > k && i * j * k == controlNumber)
  27.                         {
  28.                             isFound = true;
  29.                             Console.WriteLine("{0} * {1} * {2} = {3}", i, j, k, controlNumber);
  30.                         }
  31.                     }
  32.                 }
  33.             }
  34.             if (isFound==false)
  35.             {
  36.                 Console.WriteLine("No!");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment