-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1978.cpp
55 lines (43 loc) · 786 Bytes
/
1978.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Created by 융미 on 2019-05-23.
//*1978 소수 찾기
#include <iostream>
#include <vector>
using namespace std;
int N;
int arr[100];
bool check[100];
//재귀 아닌 버전
int findSosu(){
for(int i = 0; i< N; i++){
if(arr[i] == 1){
check[i] = true;
continue;
}
if(arr[i] == 2)
{
check[i] = false;
continue;
}
for(int j = 2; j< arr[i]; j++)
{
if((arr[i])%j == 0)
{check[i] = true; break;}
}
}
int cnt = 0;
for(int i = 0; i<N; i++)
{
if(!check[i]) cnt++;
}
cout << cnt;
}
int main() {
cin >> N;
for(int i = 0; i<N; i++)
{
cin >> arr[i];
}
findSosu();
return 0;
}