Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class 06.Сбор или Произведение {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int m = Integer.parseInt(in.nextLine());
- int count = 0;
- for (int d1 = 1; d1 <= 30; d1++) {
- for (int d2 = 1; d2 <= 30; d2++) {
- for (int d3 = 1; d3 <= 30; d3++) {
- if ((m == (d1*d2*d3)) && ((d1 > d2) && (d2 > d3))) {
- System.out.printf("%d * %d * %d = %d%n", d1, d2, d3, m);
- count++;
- } else if ((m == d1 + d2 + d3) && ((d1 < d2) && (d2 < d3))) {
- System.out.printf("%d + %d + %d = %d%n", d1, d2, d3, m);
- count++;
- }
- }
- }
- }
- if (count == 0) {
- System.out.println("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement