Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. {
  2. int input = int.Parse(Console.ReadLine());
  3. int sum;
  4. int product;
  5. bool hasNumbers = false;
  6. for (int i = 1; i <= 30; i++)
  7. {
  8. for (int j = 1; j <= 30; j++)
  9. {
  10. for (int k = 1; k <= 30; k++)
  11. {
  12. sum = i + j + k;
  13. product = i * j * k;
  14. if (sum == input)
  15. {
  16. hasNumbers = true;
  17. if(i < j && j < k)
  18. {
  19. Console.WriteLine($"{i} + {j} + {k} = {sum}");
  20. }
  21.  
  22. }
  23. if (product == input)
  24. {
  25. hasNumbers = true;
  26. if (i > j && j > k)
  27. {
  28. Console.WriteLine($"{i} * {j} * {k} = {product}");
  29. }
  30. }
  31.  
  32. }
  33. }
  34. }
  35. if (hasNumbers == false)
  36. {
  37. Console.WriteLine("No!");
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement