-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2022-04-05.cpp
More file actions
62 lines (54 loc) · 1.02 KB
/
2022-04-05.cpp
File metadata and controls
62 lines (54 loc) · 1.02 KB
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
56
57
58
59
60
61
62
#include <iostream>
#include <vector>
using namespace std;
vector<int> arr;
int* iArr;
void OddNumPrt(int x, int y) {
if (x >= y) return;
if (x % 2 == 1){
arr.push_back(x);
}
OddNumPrt(x + 1, y);
}
/// <summary>
/// 메인에 사용하는
/// </summary>
/// <returns></returns>
int UseVector() {
int x, y;
cout << "작은 수부터 두 수를 입력하시오 : " << endl;
cin >> x >> y;
OddNumPrt(x+1, y);
for(vector<int>::iterator it = arr.begin(); it != arr.end(); it++) {
cout << *it << " ";
}
return 0;
}
void OddNumPrtUseArr(int x, int y, int i = 0) {
if (x >= y) return;
if (x % 2 == 1) {
iArr[i++] = x;
}
OddNumPrtUseArr(x + 1, y, i);
}
/// <summary>
/// 메인에 사용하는
/// </summary>
/// <returns></returns>
int UseArr() {
int x, y;
cout << "작은 수부터 두 수를 입력하시오 : " << endl;
cin >> x >> y;
int iArrSize = (y - x) / 2;
iArr = new int[iArrSize];
OddNumPrtUseArr(x + 1, y);
for(int i = 0;i < iArrSize - 1; i++) {
cout << iArr[i] << " ";
}
return 0;
}
int main() {
//UseVector();
//UseArr();
return 0;
}