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