-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day5.2.cpp
35 lines (34 loc) · 893 Bytes
/
Day5.2.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
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string arr[] = { "BVWTQNHD", "BWD", "CJWQST", "PTZNRJF", "TSMJVPG", "NTFWB", "NVHFQDLB", "RFPH", "HPNLBMSZ" };
string input;
fstream file;
file.open("Day5.txt");
while (getline(file, input))
{
input.erase(0, input.find(' ') + 1);
int quantity, stack1, stack2;
quantity = stoi(input.substr(0, input.find(' ')));
input.erase(0, input.find(' ') + 1);
input.erase(0, input.find(' ') + 1);
stack1 = stoi(input.substr(0, input.find(' ')));
input.erase(0, input.find(' ') + 1);
input.erase(0, input.find(' ') + 1);
stack2 = stoi(input.substr(0, input.find(' ')));
input.clear();
stack1--;
stack2--;
arr[stack2] = arr[stack1].substr(0, quantity) + arr[stack2];
arr[stack1].erase(0, quantity);
}
file.close();
for (auto i : arr)
{
cout << i[0];
}
}