题目地址
题意
你一开始在(300,420)这个点,向四个方向走,每次走10步,第一次你向下走了10步,然后看输入,若是A就是向右拐,V就是左拐。
解题思路
控制好面向的方向就好了,主要是题意难理解
AC代码
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
while (cin >> s)
{
int a = 300, b = 420, flag = 0;
cout << a << " " << b << " moveto" << endl;
cout << a+10 << " " << b << " lineto" << endl;
a += 10;
for (int i=0; i<s.size(); i++)
{
if (s[i] == 'V')
flag = (flag + 1) % 4;
else
flag = (flag - 1 + 4) % 4;
if (flag == 0)
a += 10;
else if (flag == 1)
b += 10;
else if (flag == 2)
a -= 10;
else if (flag == 3)
b -= 10;
cout << a << " " << b << " lineto" << endl;
}
cout << "stroke\nshowpage" << endl;
}
return 0;
}