Algorithm/BOJ
백준 10807번 C++
poopooreum
2023. 9. 5. 17:21
반응형
백준 10807번
https://www.acmicpc.net/problem/10807
10807번: 개수 세기
첫째 줄에 정수의 개수 N(1 ≤ N ≤ 100)이 주어진다. 둘째 줄에는 정수가 공백으로 구분되어져있다. 셋째 줄에는 찾으려고 하는 정수 v가 주어진다. 입력으로 주어지는 정수와 v는 -100보다 크거
www.acmicpc.net


정답 코드
#include<iostream>
using namespace std;
int arr[202] = { 0 };
int main() {
int n;
cin >> n;
for (int x = 0; x < n; x++) {
int input;
cin >> input;
arr[input + 100]++;
}
int find,res=0;
cin >> find;
for (int x = 0; x < 202; x++) {
if (arr[x] > 0 && x - 100 == find) {
res = arr[x];
}
}
cout << res;
}
반응형