백준 java 10807 배열(개수세기)

임명수·2023년 5월 6일
0

백준

목록 보기
12/31

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];

        StringTokenizer st = new StringTokenizer(br.readLine());

        for(int i=0; i<arr.length; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        int searchNum = Integer.parseInt(br.readLine());
        int cnt =0;

        for(int i=0; i<arr.length; i++){
            if(arr[i] == searchNum){
                cnt++;
            }
        }
        System.out.println(cnt);
        br.close();

    }
}
profile
푸른영혼의별

0개의 댓글