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. LRC歌词文件读取代码

    /**************************************************/ /*******************-main文件-******************* ...

  2. zabbix实现mysql数据库的监控(一)

    zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.它能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问 ...

  3. 解决ul里最后一个li的margin问题

    在html+css布局里ul>li挺常用的,在群里(WEB前端开发 458732443)总有新手问怎么解决li的最后一个margin值的问题.下面介绍一下,大神请不要拍砖. 先看两个demo,你 ...

  4. EntityFramework 学习 一 Update Existing Entity using DBContext in Disconnected Scenario

    using System; using System.Collections.Generic; public partial class Student { public Student() { th ...

  5. Blog迁移至Jekyll

    后续的Blog都将在 http://zhwbqd.github.io/ 为您呈现

  6. 四分位数及matlab实现

    四分位数(quantile),解释及调用形式如下. quantile(x,y,z)的三个参数的说明如下:x表示要求的矩阵或者向量:y的取值为表示要求的分位数,如四分之一中位数0.25,四分之三中位数0 ...

  7. (转)JSP九大内置对象

    原文出处:http://www.importnew.com/19128.html 虽然现在基本上使用SpringMVC+AJAX进行开发了Java Web了,但是还是很有必要了解一下JSP的九大内置对 ...

  8. appium界面元素介绍

    一.主窗口 主页面顶部从左到右依次是: AndroidSettings:android相关的设置 GeneralSettings:全局设置,设置appium相关的内容 DeveloperSetting ...

  9. Javascript-- jQuery DOM篇(二)

    DOM拷贝clone() 克隆节点是DOM的常见操作,jQuery提供一个clone方法,专门用于处理dom的克隆 .clone()方法深度 复制所有匹配的元素集合,包括所有匹配元素.匹配元素的下级元 ...

  10. 用cookie登录慕课网络教学中心刷评论

    声明:本文仅供学习参考 我们学校和的网络教学平台是在慕课网上的,需要登录到慕课网的教学平台以后,拿到cookie 注意:没次提交后需要休眠,否则刷评论过快会被系统发现 如果请求太快,很容易被系统发现( ...