문제
https://www.acmicpc.net/problem/10807
10807번: 개수 세기
첫째 줄에 정수의 개수 N(1 ≤ N ≤ 100)이 주어진다. 둘째 줄에는 정수가 공백으로 구분되어져있다. 셋째 줄에는 찾으려고 하는 정수 v가 주어진다. 입력으로 주어지는 정수와 v는 -100보다 크거
www.acmicpc.net
코드
import java.util.*;
import java.io.*;
class Main {
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int arr [] = new int [202];
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
int num = Integer.parseInt(st.nextToken());
arr[num+100] +=1;
}
int idx = Integer.parseInt(br.readLine());
System.out.print(arr[idx+100]);
}
}