-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
79 lines (58 loc) · 1.4 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "policies.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
extern int GenerateEntries(int, int, int, int*);
using namespace std;
int test1()
{
cout << "test1" << endl;
int tc;
cin >> tc;
while(tc--)
{
int s, n, m;
cin >> s >> n >> m;
int entries[m];
for(int i = 0; i < m; ++i)
cin >> entries[i];
bool cached[n + 1];
cout << FIFO(s, n, m, cached, entries) << " ";
cout << LIFO(s, n, m, cached, entries) << " ";
cout << LRU(s, n, m, cached, entries) << " ";
cout << OPT(s, n, m, cached, entries) << endl;
}
return 0;
}
int test2()
{
cout << "test2" << endl;
int tc;
cin >> tc;
while(tc--)
{
int s, p, x, q;
cin >> s >> p >> x >> q;
// num of entries
int n = p * x + x * q + p * q;
// num of access
int m = (x * 2 + 1) * p * q;
int entries[m];
GenerateEntries(p, x, q, entries);
bool cached[n + 1];
// cout << FIFO(s, n, m, cached, entries) << " ";
cout << LIFO(s, n, m, cached, entries) << " ";
// cout << LRU(s, n, m, cached, entries) << " ";
// cout << OPT(s, n, m, cached, entries) << endl;
}
return 0;
}
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
test1();
test2();
system("PAUSE");
return 0;
}