Advertisement
Guest User

6

a guest
Jun 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 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 exam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int controlnum = int.Parse(Console.ReadLine());
  14.             int a = 1;
  15.             int add = 0;
  16.             int multiply = 0;
  17.  
  18.             for (; a <=30 ; a++)
  19.             {
  20.                 for (int b = 1; b <= 30 ; b++)
  21.                 {
  22.                     for (int c = 1; c <= 30; c++)
  23.                     {
  24.                         add = a + b + c;
  25.                         multiply = a * b * c;
  26.                         if (a < b && b < c)
  27.                         {
  28.                             if (add == controlnum)
  29.                             {
  30.                                 Console.WriteLine($"{a} + {b} + {c} = {controlnum}");
  31.                             }
  32.                                
  33.                         }
  34.                         if (a > b && b > c)
  35.                         {
  36.                             if (multiply == controlnum)
  37.                             {
  38.                                 Console.WriteLine($"{a} * {b} * {c} = {controlnum}");
  39.                             }
  40.                         }
  41.                     }
  42.                 }
  43.             }
  44.             if (controlnum == 0 && multiply == 0)
  45.             {
  46.                 Console.WriteLine("No!");
  47.             }
  48.            
  49.  
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement