hdu_1033(我怎么找到的这么水的题,只为保存代码。。。)
2017-08-09 16:39
274 查看
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 const int Max = 250; 7 int ansx[Max],ansy[Max]; 8 //0,1,2,3表示方向,顺时针标注 9 void ans(int tx,int ty, int dir,int id) 10 { 11 if(dir == 0){ 12 ansx[id+1] = tx+10; 13 ansy[id+1] = ty; 14 } 15 else if(dir == 1){ 16 ansx[id+1] = tx; 17 ansy[id+1] = ty+10; 18 } 19 else if(dir == 2){ 20 ansx[id+1] = tx-10; 21 ansy[id+1] = ty; 22 } 23 else if(dir == 3){ 24 ansx[id+1] = tx; 25 ansy[id+1] = ty-10; 26 } 27 } 28 int main() 29 { 30 int dir = 0; 31 char query[Max]; 32 while(~scanf("%s",query)) 33 { 34 dir = 0; 35 ansx[0] = 310,ansy[0] = 420; 36 int len = strlen(query); 37 for(int i = 0; i < len; i++) 38 { 39 if(query[i]=='V') { 40 dir = (dir+5)%4; 41 ans(ansx[i],ansy[i],dir,i); 42 } 43 else if(query[i]=='A'){ 44 dir = (dir+3)%4; 45 ans(ansx[i],ansy[i],dir,i); 46 } 47 } 48 printf("300 420 moveto\n"); 49 for(int i = 0; i <= len; i++){ 50 printf("%d %d lineto\n",ansx[i],ansy[i]); 51 } 52 printf("stroke\nshowpage\n"); 53 } 54 return 0; 55 }
相关文章推荐
- 怎么从Backtrace log,找到对应的代码行
- IIS 部署网站 提示 让你保存 或者在线找到打开程序 该怎么办?
- 怎么java的代码看着这么恶心~~?
- AndroidSdk开发,混淆后的代码出现bug后怎么找到bug位置
- 这个天气怎么就这么热啊,哪里还有心情写代码呀。
- CSDN博客插入代码怎么这么难弄???
- 怎么找到android系统input命令的实现代码
- dedecms编辑源代码保存之后再次编辑代码变了格式请问怎么弄?
- 怎么使用jstack精确找到异常代码
- 天气这么冷,你们是怎么保证写代码的时候手不冷的呢?
- [VB.NET]VB.NET中用drawImage()画图以后怎么保存?程序代码如下:
- 找了这么长时间才找到适合写代码的BLOG
- 对于一个表中字段保存的是代码,怎么用Struts+Hibernate将名称显示出来
- 保存oralce的TIMESTAMP类型的字段,java代码应该怎么写?
- 对现有的所能找到个DDOS代码(攻击模块)做出一次分析----TCP篇
- 怎么把种子文件里面的电影保存到网盘里面?
- 诊断Java代码中常见的数据库性能热点问题应该这么做!
- 读懂IL代码就这么简单(一)
- 这么糟糕的代码,真的是我以前写的吗?
- Python爬取微软学术保存数据库(代码粗略有待完善~)