Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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 MathPuzzle
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int key = int.Parse(Console.ReadLine());
  14. int count = 0;
  15.  
  16. for (int a = 1; a <= 30; a++)
  17. {
  18. for (int b = 1; b <= 30; b++)
  19. {
  20. for (int c = 1; c <= 30; c++)
  21. {
  22. if ((a < b) && (b < c) && (a + b + c == key))
  23. {
  24. Console.WriteLine($"{a} + {b} + {c} = {key}");
  25. count++;
  26. }
  27. if ((a > b) && (b > c) && (a * b * c == key))
  28. {
  29. Console.WriteLine($"{a} * {b} * {c} = {key}");
  30. count++;
  31. }
  32. }
  33. }
  34. }
  35. if (count == 0) Console.WriteLine("No!");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement