-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJosephus.cpp
More file actions
52 lines (43 loc) · 806 Bytes
/
Copy pathJosephus.cpp
File metadata and controls
52 lines (43 loc) · 806 Bytes
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
//
#include "pch.h"
#include "Solver.h"
int main()
{
Solver josephus;
unsigned __int32 n, k, s;
while (true)
{
system("cls");
std::cout << "Number of soldiers: ";
std::cin >> n;
if (!n)
{
return 0;
}
std::cout << "Execution step: ";
std::cin >> k;
std::cout << "How many survivors (Optionel - Type 0 to pass this option): ";
std::cin >> s;
std::cout << std::endl << "Survivor: ";
if (s == 0)
{
s = 1;
}
if (s == 1)
{
std::cout << ": " << josephus.findSurvivors(n, k);
josephus.getExecutionList(n, k);
}
else
{
std::cout << "s: ";
for (unsigned __int32 i = 0; i < s; i++)
{
std::cout << josephus.findSurvivors(n, k, s);
}
josephus.getExecutionList(n, k, s);
}
std::cout << std::endl << std::endl;
system("pause");
}
}