-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirection.cpp
More file actions
51 lines (42 loc) · 1.14 KB
/
direction.cpp
File metadata and controls
51 lines (42 loc) · 1.14 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
#include <iostream>
using namespace std;
enum directionT {
North,
East,
South,
West
};
directionT LeftFrom(directionT dir) {
return directionT((dir+3)%4);
}
directionT RightFrom(directionT dir) {
return directionT((dir+1)%4);
}
string DirString(directionT dir) {
switch (dir) {
case North : return "North";
case East : return "East";
case South : return "South";
case West : return "West";
default : return "";
}
}
int main() {
directionT dir = directionT(North);
dir = LeftFrom(dir);
cout << "Left From North " << DirString(dir) << endl;
dir = LeftFrom(dir);
cout << "Left From West " << DirString(dir) << endl;
dir = LeftFrom(dir);
cout << "Left From South " << DirString(dir) << endl;
dir = LeftFrom(dir);
cout << "Left From East " << DirString(dir) << endl;
dir = RightFrom(dir);
cout << "Right From North " << DirString(dir) << endl;
dir = RightFrom(dir);
cout << "Right From East " << DirString(dir) << endl;
dir = RightFrom(dir);
cout << "Right From South " << DirString(dir) << endl;
dir = RightFrom(dir);
cout << "Right From West " << DirString(dir) << endl;
}