-
Notifications
You must be signed in to change notification settings - Fork 0
/
segmentation 43.cpp
53 lines (49 loc) · 1.1 KB
/
segmentation 43.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
#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int ba[4],bo[4],seg[4];
int v,s;
int o,temp;
string a[4],v_a;
for(int i=0; i<4; i++)
{
cin>>ba[i]>>bo[i];
cin>>a[i];
}
for(int i=0; i<4; i++)
{
seg[i]=ba[i]+bo[i];
}
while(cin>>v>>v_a)
{
s=v>>10;
o=v&1023;
if(s>=0&&s<=3)
{
temp=o+ba[s];
if(temp>=ba[s]&&temp<=seg[s])
{
if(a[s]==v_a)
{
cout<<"Access granted..."<<endl;
}
else if(a[s]=="RW")
{
cout<<"Access granted..."<<endl;
}
else
cout<<"Access denied..."<<endl;
}
else
cout<<"Access denied..."<<endl;
}
else
cout<<"Access denied..."<<endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}