import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int count = 0;
int[] arr = new int[N];
for(int i = 0; i < N; i++)
arr[i] = sc.nextInt();
int V = sc.nextInt();
for(int i = 0; i < N; i++)
if(arr[i] == V)
count++;
System.out.println(count);
}
}
배열 선언 방법
자료형[] 변수 = new 자료형[배열의크기];
변수[0] = 데이터;
or
자료형[] 변수 = {데이터};
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준_JAVA] 27323 직사각형 (0) | 2023.07.30 |
---|---|
[백준_JAVA] 10871 X보다 작은 수 (0) | 2023.07.30 |
[백준_JAVA] 2444 별 찍기 - 7 (0) | 2023.07.28 |
[백준_JAVA] 3003 킹, 퀸, 룩, 비숍, 나이트, 폰 (0) | 2023.07.27 |
[백준_JAVA] 25083 새싹 (0) | 2023.07.25 |