#include <iostream>
#include <fstream>
#include <string>
#include <locale>
#include <vector>
using namespace std;
int arr[256] = { 0 };
int obrabotka(char sim, int select) {
if (sim == '>') {
++select;
}
if (sim == '<' && select > 0) {
--select;
}
if (sim == '+') {
++arr[select];
}
if (sim == '-') {
--arr[select];
}
if (sim == '.') {
cout << arr[select];
}
if (sim == ',') {
cin >> arr[select];
}
return select;
}
int main() {
setlocale(LC_ALL, "Russian");
int select = 0;
int selectCikl = 0;
string line;
ifstream in;
in.open("main.bf");
if (in.is_open()) {
while (getline(in, line)) {
for (int i = 0; i < line.size(); i++) {
char sim = line[i];
if (sim == '[') {
selectCikl = select;
while (arr[selectCikl] != 0) {
select = obrabotka(sim, select);
arr[selectCikl]--;
}
}
else {
select = obrabotka(sim, select);
}
}
}
}
return 0;
}