Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MathPuzzle
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int K = int.Parse(Console.ReadLine());
  10.  
  11. int muster = 0;
  12. int multiplication = 0;
  13. bool nonum = false;
  14.  
  15. for (int a = 1; a <= 30; a++)
  16. {
  17. for (int b = 1; b <= 30; b++)
  18. {
  19. for (int c = 1; c <= 30; c++)
  20. {
  21. muster = a + b + c;
  22. multiplication = a * b * c;
  23.  
  24. if (muster == K)
  25. {
  26. if (a < b && b < c)
  27. {
  28. Console.WriteLine($"{a} + {b} + {c} = {muster}");
  29. nonum = true;
  30. }
  31. }
  32. else if (multiplication == K)
  33. {
  34. if (a > b && b > c)
  35. {
  36. Console.WriteLine($"{a} * {b} * {c} = {multiplication}");
  37. nonum = true;
  38. }
  39. }
  40.  
  41. }
  42.  
  43. }
  44.  
  45. }
  46. if (nonum==false)
  47. {
  48. Console.WriteLine("No!");
  49. }
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement