HDACM 1033
题意就是 画线,A表示顺时针旋转90度,v表示逆时针旋转90度。
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()) {String str = sc.next();System.out.println("300 420 moveto");System.out.println("310 420 lineto");int x = 310;int y = 420;int dirct = 1; // 1左,3右,0上,2下int i = 0;while (i < str.length()) {if (str.charAt(i) == 'A') {dirct = (dirct + 1) % 4;} else {dirct = (dirct - 1 + 4) % 4;}switch (dirct) {case 0:y += 10;break;case 1:x += 10;break;case 2:y -= 10;break;case 3:x -= 10;break;}System.out.println(x+" "+y+" lineto");i++;}System.out.println("stroke");System.out.println("showpage");}sc.close();}}