#include #include #include using namespace std; int main() { ifstream cin("edge.in"); string input; int direction = 1; int x = 0, y = 0; while(true) { getline(cin, input); if(!cin) break; direction = 1; //output standard stuff cout << "300 420 moveto" << endl; cout << "310 420 lineto" << endl; x = 310; y = 420; for(unsigned int i = 0; i < input.length(); i++) { //calculate foldings switch(direction) { case 0: if(input[i] == 'V') { direction = 3; x -= 10; } else { direction = 1; x += 10; } break; case 1: if(input[i] == 'V') { direction = 0; y += 10; } else { direction = 2; y -= 10; } break; case 2: if(input[i] == 'V') { direction = 1; x += 10; } else { direction = 3; x -= 10; } break; case 3: if(input[i] == 'V') { direction = 2; y -= 10; } else { direction = 0; y += 10; } } cout << x << " " << y << " lineto" << endl; } //output other standard stuff cout << "stroke" << endl; cout << "showpage" << endl; } }