Guest User

Untitled

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