728x90
각 숫자에 대한 배열을 만들고 수가 나올때마다
배열의 값을 1씩 추가해줘서 개수를 저장해둡니다.
그리고 찾는 숫자가 있는 배열위치의 값을 출력하면 됩니다.
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
int main(int argc, char * argv[])
{
int n;
int num;
int find;
int arr[210];
cin >> n;
memset(arr, 0, sizeof(arr));
for (int i = 0; i < n; ++i) {
cin >> num;
++arr[num + 100];
}
cin >> find;
cout << arr[find + 100] << endl;
return 0;
}
'알고리즘' 카테고리의 다른 글
[C++] 백준 2607번 비슷한 단어 (0) | 2019.09.19 |
---|---|
[C++] 백준 2563번 색종이 (0) | 2019.09.19 |
[C++] 백준 2309번 일곱 난쟁이 (0) | 2019.09.19 |
[C++] 백준 9660번 돌 게임 6 (0) | 2019.09.18 |
[C++] 백준 9659번 돌 게임 5 (0) | 2019.09.18 |