Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by karay on 6/25/2017.
- */
- public class p06 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int num = Integer.parseInt(scanner.nextLine());
- //int counter = 0;
- boolean flag = false; // деклариране на флага
- 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) {
- if (a + b + c == num) {
- System.out.printf("%d + %d + %d = %d%n", a, b, c, num);
- //counter++;
- flag = true; // Промяна на стойността му на вярно
- }
- }
- if (a > b && b > c) {
- if (a * b * c == num) {
- System.out.printf("%d * %d * %d = %d%n", a, b, c, num);
- // counter++;
- flag = true; // Промяна на стойността му на вярно
- }
- }
- }
- }
- }
- // if (counter < 1){
- // System.out.printf("No!");
- // }
- if (!flag) { //Проверка на флага
- System.out.println("No!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement