码迷,mamicode.com
首页 > 其他好文 > 详细

HDUOJ 1033 Edge

时间:2015-10-06 12:52:54      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

看到百分之50多的AC率,但这道题看得我一头雾水。。。看了半天结果就是一道大水题。模拟就行了。

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     char command[201];
 9     int len, x, y, i, cur_direction;                  //cur_direction: 1 means north, 2 means east, 3 means south, 4 means west
10     while(scanf("%s", command) != EOF)
11     {
12         len = strlen(command);
13         printf("300 420 moveto\n310 420 lineto\n");
14         i = 0; x = 310; y = 420;
15         cur_direction = 2;
16         while(i < len)
17         {
18             switch(cur_direction)
19             {
20             case 1:
21                 if(V == command[i]) {printf("%d %d lineto\n", x-=10, y); cur_direction = 4;}
22                 else {printf("%d %d lineto\n", x+=10, y); cur_direction = 2;}
23                 break;
24             case 2:
25                 if(V == command[i]) {printf("%d %d lineto\n", x, y+=10); cur_direction = 1;}
26                 else {printf("%d %d lineto\n", x, y-=10); cur_direction = 3;}
27                 break;
28             case 3:
29                 if(V == command[i]) {printf("%d %d lineto\n", x+=10, y); cur_direction = 2;}
30                 else {printf("%d %d lineto\n", x-=10, y); cur_direction = 4;}
31                 break;
32             case 4:
33                 if(V == command[i]) {printf("%d %d lineto\n", x, y-=10); cur_direction = 3;}
34                 else {printf("%d %d lineto\n", x, y+=10); cur_direction = 1;}
35                 break;
36             }
37             ++i;
38         }
39         printf("stroke\nshowpage\n");
40     }
41     return 0;
42 }

 

HDUOJ 1033 Edge

标签:

原文地址:http://www.cnblogs.com/Artprog/p/4856966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!