-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDumbBrainF.cpp
59 lines (44 loc) · 1.27 KB
/
DumbBrainF.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
// UNFINISHED AND REALLY DUMB IMPLEMENTATION OF BRAINF*** WITHOUT ANY GOING BACK :)
/*
* PRINT "HI"
* up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-down-out-next-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-up-down-out
*/
#include <bits/stdc++.h>
using namespace std;
void pincr(int ptr) {
++ptr;
}
void bincr(int data[], int ptr) {
++data[ptr];
}
void puts(int data[], int ptr) {
cout << (char) (data[ptr] + 32);
}
void gets(int data[], int ptr) {
cin >> data[ptr];
}
void run(vector<string> code) {
int MAX = 1000;
int data[MAX];
int ptr = 0;
for (auto tk : code) {
if (data[ptr] <= 18) {
if (tk == "up") { bincr(data, ptr); }
}
if (data[ptr] > 18) {
if (tk == "down") { bincr(data, ptr); }
}
if (tk == "next") { pincr(ptr); }
if (tk == "out") { puts(data, ptr); }
}
}
int main() {
vector<string> code;
string s, temp;
cin >> s;
stringstream ss(s);
while (getline(ss, temp, '-')) {
code.push_back(temp);
}
run(code);
}