PS/BaekJoon

3052 JAVA ๋‚˜๋จธ์ง€

chaerlo127 2022. 6. 30. 23:04
728x90

 

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int input = 0;
		int[] a = new int [10];
		for(int i = 0; i<10 ; i++) {
			input = scanner.nextInt();
			a[i] = input%42;
		}
		scanner.close();
		//int count = 0;
		int countPer = 0;
		for(int i = 0; i<10 ; i ++) {
			int count = 0;
			for(int j = i+1; j<10 ; j++) {
				if(a[i] == a[j]) {
					count++;
				}
			}
			if(count == 0) countPer++;
		}
		System.out.println(countPer);
	}
}

 

int count๋ฅผ ์ดˆ๊ธฐํ™” ํ• ๋•Œ์—๋Š” for๋ฌธ์ด ๋ฐœ์ƒํ•  ๋•Œ๋งˆ๋‹ค ๋˜์–ด์•ผ ํ•˜๋ฏ€๋กœ for ๋ฌธ ๋ฐ–์—์„œ ์ดˆ๊ธฐํ™” ๋˜์–ด์•ผํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ,

for๋ฌธ ์•ˆ์—์„œ ์ดˆ๊ธฐํ™”๊ฐ€ ๋˜์–ด์•ผ ํ•œ๋‹ค.

728x90