Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class twoKone {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. int key = Integer.parseInt(scanner.nextLine());
  9. int count = 0;
  10.  
  11. for (int a = 1; a <= 30; a++) {
  12. for (int b = 1; b <= 30; b++) {
  13. for (int c = 1; c <= 30; c++) {
  14.  
  15. if ((a < b) && (b < c) && (a + b + c == key)) {
  16.  
  17. System.out.printf("%d + %d + %d = %d",a,b,c,key);
  18. count++;
  19. }
  20. if ((a > b) && (b > c) && (a * b * c == key)) {
  21.  
  22. System.out.printf("%d * %d * %d = %d", a, b, c, key).println();
  23. count++;
  24. }
  25. }
  26. }
  27. }
  28. if (count == 0) {
  29. System.out.println("No!");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement