문제 출처 : https://www.acmicpc.net/
#10807: 개수 세기 (언어 : Java11)
제출 답안
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] arr = new int[sc.nextInt()];
for(int i=0; i<arr.length; i++)
arr[i] = sc.nextInt();
int a = sc.nextInt();
int count = 0;
for (int num : arr){
if (num == a)
count++;
}
System.out.println(count);
}
}
comment
- 반복문 말고 관련 함수 있는지 찾아보기
'Study📚 > 백준' 카테고리의 다른 글
[백준] - #2739: 구구단 (0) | 2024.05.14 |
---|---|
[백준] - #10871: X보다 작은 수 (0) | 2024.05.13 |
[백준] - #10998: AxB (0) | 2024.05.13 |
[백준] - #2480: 주사위 세개 (0) | 2024.05.13 |
[백준] - #2588: 곱셈 (0) | 2024.05.13 |