-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2022-04-06.cpp
More file actions
68 lines (59 loc) · 1 KB
/
2022-04-06.cpp
File metadata and controls
68 lines (59 loc) · 1 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
63
64
65
66
67
68
#include <iostream>
using namespace std;
int GetMaxInArr(int* arr, int i = 0, int max = 0)
{
if (i == 0)
{
max = arr[0];
}
if (arr[i] > max)
{
max = arr[i];
}
if (i == 4)
{
return max;
}
return GetMaxInArr(arr, i + 1, max);
}
int FindMaxNum() {
int num[5];
cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];
cout << GetMaxInArr(num) << endl;
return 0;
}
int FindGreatestCommonFactor(int x, int y) {
int temp = x % y;
if (temp == 0)
{
return y;
}
return FindGreatestCommonFactor(y, temp);
}
int GreatestCommonFactor() {
int x, y;
cin >> x >> y;
cout << FindGreatestCommonFactor(x, y) << endl;
return 0;
}
int Factorial(int num) {
if (num == 1) {
return 1;
}
return num * Factorial(num - 1);
}
int Combination(int n, int r)
{
return (Factorial(n)/(Factorial(n-r)*Factorial(r)));
}
int FindCombination() {
int n, r;
cin >> n >> r;
cout << Combination(n, r) << endl;
return 0;
}
int main() {
//return FindMaxNum();
//return GreatestCommonFactor();
return FindCombination();
}