View difference between Paste ID: L3vPB8BU and cWjVWrGc
SHOW: | | - or go back to the newest paste.
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;
10+
        //int counter = 0;
11
		boolean flag = false; // деклариране на флага
12
13
        for (int a = 1; a <= 30; a++) {
14
            for (int b = 1; b <= 30; b++) {
15
                for (int c = 1; c <= 30; c++) {
16
                    if (a < b && b < c) {
17
                        if (a + b + c == num) {
18-
                            counter++;
18+
19
                            //counter++;
20
							flag = true; // Промяна на стойността му на вярно
21
                        }
22
                    }
23
                    if (a > b && b > c) {
24-
                            counter++;
24+
25
                            System.out.printf("%d * %d * %d = %d%n", a, b, c, num);
26
                            // counter++;
27
							flag = true; // Промяна на стойността му на вярно
28
                        }
29
                    }
30-
        if (counter < 1){
30+
31-
            System.out.printf("No!");
31+
32
        }
33
       // if (counter < 1){
34
       //     System.out.printf("No!");
35
       // }
36
			if (!flag) {				//Проверка на флага
37
            System.out.println("No!");
38
        }
39
    }
40
}