Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Math_Puzzle
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int key = int.Parse(Console.ReadLine());
  12. int counter = 0;
  13.  
  14. for (int a = 1; a <= 30; a++)
  15. {
  16. for (int b = 1; b <= 30; b++)
  17. {
  18. for (int c = 1; c <= 30; c++)
  19. {
  20. if (a + b + c == key)
  21. {
  22. if (a < b && b < c) { Console.WriteLine($"{a} + {b} + {c} = {key}");
  23. counter++;
  24. }
  25. }
  26.  
  27.  
  28. else if (a * b * c == key)
  29. {
  30. if (a > b && b > c) { Console.WriteLine($"{a} * {b} * {c} = {key}");
  31. counter++;
  32. }
  33. }
  34.  
  35. }
  36. }
  37. }
  38. if (counter == 0) { Console.WriteLine("No!"); }
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement