Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class twoKone {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int key = Integer.parseInt(scanner.nextLine());
- int count = 0;
- for (int a = 1; a <= 30; a++) {
- for (int b = 1; b <= 30; b++) {
- for (int c = 1; c <= 30; c++) {
- if ((a < b) && (b < c) && (a + b + c == key)) {
- System.out.printf("%d + %d + %d = %d",a,b,c,key);
- count++;
- }
- if ((a > b) && (b > c) && (a * b * c == key)) {
- System.out.printf("%d * %d * %d = %d", a, b, c, key).println();
- count++;
- }
- }
- }
- }
- if (count == 0) {
- System.out.println("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement