Problem Description
For products that are wrapped in small packings it is necessary that the sheet of paper containing the directions for use is folded until its size becomes small enough. We assume that a sheet of paper is rectangular and only folded along lines parallel to its initially shorter edge. The act of folding along such a line, however, can be performed in two directions: either the surface on the top of the sheet is brought together, or the surface on its bottom. In both cases the two parts of the rectangle that are separated by the folding line are laid together neatly and we ignore any differences in thickness of the resulting folded sheet. 
After several such folding steps have been performed we may unfold the sheet again and take a look at its longer edge holding the sheet so that it appears as a one-dimensional curve, actually a concatenation of line segments. If we move along this curve in a fixed direction we can classify every place where the sheet was folded as either type A meaning a clockwise turn or type V meaning a counter-clockwise turn. Given such a sequence of classifications, produce a drawing of the longer edge of the sheet assuming 90 degree turns at equidistant places.
 
Input
The input contains several test cases, each on a separate line. Each line contains a nonempty string of characters A and V describing the longer edge of the sheet. You may assume that the length of the string is less than 200. The input file terminates immediately after the last test case.
 
Output
For each test case generate a PostScript drawing of the edge with commands placed on separate lines. Start every drawing at the coordinates (300, 420) with the command "300 420 moveto". The first turn occurs at (310, 420) using the command "310 420 lineto". Continue with clockwise or counter-clockwise turns according to the input string, using a sequence of "x y lineto" commands with the appropriate coordinates. The turning points are separated at a distance of 10 units. Do not forget the end point of the edge and finish each test case by the commands stroke and showpage.

You may display such drawings with the gv PostScript interpreter, optionally after a conversion using the ps2ps utility.

 
Sample Input
V
AVV
 
Sample Output
300 420 moveto
310 420 lineto
310 430 lineto
stroke
showpage
300 420 moveto
310 420 lineto
310 410 lineto
320 410 lineto
320 420 lineto
stroke
showpage
本题比较简单,就是一个折纸游戏,当输入V时要求逆时针折纸,输入A时顺时针折纸
下面代码中,flag用以表示上次折纸的方向,1,2,3,4分别为上下左右....
 /**********************************************
杭电acm 1033题 已AC
***********************************************/
#include <iostream>
using namespace std;
int main(void)
{
char test[];
int len;
int flag;//1,2,3,4分别代表上下左右
int edge[]={,};
while(scanf("%s",test)!=EOF)
{
len=strlen(test);
for(int i=;i<len;i++)
{
if(i==&&test[i]=='V')
{
cout<<edge[]<<" "<<edge[]<<" "<<"moveto"<<endl;
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
}
if(i==&&test[i]=='A')
{
cout<<edge[]<<" "<<edge[]<<" "<<"moveto"<<endl;
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
edge[]-=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
}
if(i>&&flag==&&test[i]=='V')//以下考虑八种情况即可,每次情况只执行一次,否则输出会有问题
{
edge[]-=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='V')
{
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='V')
{
edge[]-=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='V')
{
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
} if(i>&&flag==&&test[i]=='A')
{
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='A')
{
edge[]-=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='A')
{
edge[]+=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
if(i>&&flag==&&test[i]=='A')
{
edge[]-=;
cout<<edge[]<<" "<<edge[]<<" "<<"lineto"<<endl;
flag=;
continue;
}
}
cout<<"stroke"<<endl<<"showpage"<<endl;
edge[]=;
edge[]=; }
return ;
}

程序考虑八种情况即可....

杭电acm 1033题的更多相关文章

  1. 杭电acm 1076题

    水题,一个求闰年的题目,复习一下闰年的求法.... 1,如果能被4整除但不能被100整除的是闰年 2,能被400整除的是闰年 题目大意是:给定一个开始年份T以及一个正数N,要求求出从T开始,到了哪一年 ...

  2. 杭电acm 1037题

    本题应该是迄今为止最为简单的一道题,只有一组输入,输出也简单.... /****************************************** 杭电acm 1037题 已AC ***** ...

  3. 杭电acm 1038题

    本题比较简单,但是需要掌握几个小技巧,先上代码 /************************************* 杭电ACM 1038题,已AC ********************* ...

  4. 杭电acm 1049题

    一道水题..... 大意是一条1inch的虫子在一个n inch的盒子的底部,有足够的能够每一分钟往上爬u inch,但是需要休息一分钟,这期间会往下掉d inch,虫子爬到盒子口即认为结束.要求计算 ...

  5. 杭电ACM刷题(1):1002,A + B Problem II 标签: acmc语言 2017-05-07 15:35 139人阅读 评

    最近忙于考试复习,没有多少可供自己安排的时间,所以我利用复习之余的空闲时间去刷刷杭电acm的题目,也当对自己编程能力的锻炼吧. Problem Description I have a very si ...

  6. 杭电acm刷题顺序

    最近兴趣来了,闲暇之余,回顾大学期间刷过的杭电acm那些入门级别的题,以此巩固基础知识! 以下参考刷题顺序,避免入坑 原文传送门:https://blog.csdn.net/liuqiyao_01/a ...

  7. 杭电acm 1015题

    马上要找工作了,锻炼下自己的写程序能力,不多说,上代码 /********************杭电acm 1015 已AC 在这个程序里,使用穷举法来实现,但是输出顺序需要安装字典的最大 来输出 ...

  8. 杭电acm 1040题

    本题是一个非常简单的升序排序题目,但那时在做的时候把题目看错了,导致花费了大量的时间来检查为什么WA,最后发现题目看错了..... /********************************* ...

  9. 杭电acm 1098题

    Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice bu ...

随机推荐

  1. Yii2学习笔记---内附GridView配置总结

    1./vendor/yiisoft/yii2/web/UrlManager.php 方法createUrl 修改url参数转码2.config/web.php 配置文件Yii::$app(应用主体)的 ...

  2. Spring Cloud之Zuul负载均衡

    Zuul网关默认是实现负载均衡的,不需要任何配置.默认开启ribbon效果的 可以启启动两个服务端口,访问下.

  3. jQuery横向手风琴图片滑块

    jQuery横向手风琴图片滑块是一款非常不错的jQuery特效横向手风琴图片滑块插件,可以自动播放,也可以鼠标滑过时切换.+ 欢迎喜欢的朋友下载研究 源码下载页:http://www.huiyi8.c ...

  4. L103

    Give everyday the chance to become the most beautiful day of your life.把每天都过成你生命中最美好的一天.competence 能 ...

  5. codeforces 710B B. Optimal Point on a Line(数学)

    题目链接: B. Optimal Point on a Line 题意: 给出n个点,问找出一个点使得这个点到所有的点的距离和最小; 思路: 所有点排序后的中位数;这是一个结论; AC代码: #inc ...

  6. 七牛 python

    Python SDK使用指南 上传策略 变量 对象存储 API 参考手册 多媒体数据处理 API 参考手册

  7. 关于avpicture_fill 和 sws_scale的关系

    avpicture_fill((AVPicture *) pFrameRGB, buffer, PIX_FMT_RGB565, pCodecCtx->width, pCodecCtx->h ...

  8. loj515贪心只能过样例

    bitset练习题... 位运算真的是玄学... 一开始真的“只能过样例” 后来发现把左移写成了小于号 鬼知道我在想什么/手动微笑 loj第一题 #include<iostream> #i ...

  9. CodeForces - 1017F. The Neutral Zone (数学+Bitset存素数+素数筛优化)

    Notice: unusual memory limit! After the war, destroyed cities in the neutral zone were restored. And ...

  10. BZOJ4545: DQS的trie

    BZOJ4545: DQS的trie https://lydsy.com/JudgeOnline/problem.php?id=4545 分析: 对trie用dfs建sam复杂度是\(O(n^2)\) ...