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. pandas to_datetime()

    >>> import pandas as pd >>> i = pd.date_range() >>> df = pd.DataFrame(dic ...

  2. Spark Structured Streaming框架(2)之数据输入源详解

    Spark Structured Streaming目前的2.1.0版本只支持输入源:File.kafka和socket. 1. Socket Socket方式是最简单的数据输入源,如Quick ex ...

  3. Vue 5小时学习小教程

    Vue Vue Vue 起步 指令 v-bind v-if v-for v-on v-model v-bind和v-on缩写 搭建Vue开发环境 vue项目结构 Vue开始 数据绑定, 绑定属性 循环 ...

  4. SiteServer CMS 5.0 源码入门

    开发者中心 STL 语言 文 档 博 客 论 坛 Github 二次开发 提示:文档中心正在完善中,我们将不断发布新文档,敬请期待...   新手入门 SiteServer CMS 能做什么 Site ...

  5. 《python基础教程(第二版)》学习笔记 列表/元组(第2章)

    <python基础教程(第二版)>学习笔记 列表/元组(第2章)序列中的下标从0开始x='ABC' ==> x[0]='A', x[1]='B', x[2]='C'负数索引从右边开始 ...

  6. Codeforces 402D Upgrading Array:贪心 + 数学

    题目链接:http://codeforces.com/problemset/problem/402/D 题意: 给你一个长度为n的数列a[i],又给出了m个“坏质数”b[i]. 定义函数f(s),其中 ...

  7. CommonJS、AMD与CMD

    自从有了模块,我们可以更方便地使用别人的代码,想要什么功能,就加载什么模块.但是,这样做有一个前提,那就是大家必须以同样的方式编写模块,否则你有你的写法,我有我的写法,岂不是乱了套! 于是下面三个模块 ...

  8. python 面试题(一)

    1 Python的函数参数传递 看两个例子: Python   1 2 3 4 5 a = 1 def fun(a):     a = 2 fun(a) print a  # 1   Python   ...

  9. C++内存使用机制基本概念详解

    .程序使用内存区 一个程序占用的内存区一般分为5种: ()全局.静态数据区:存储全局变量及静态变量(包括全局静态变量和局部静态变量) ()常量数据区:存储程序中的常量字符串等. ()代码区:存储程序的 ...

  10. 【遍历二叉树】09判断二叉树是否关于自己镜像对称【Symmetric Tree】

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 给定一个二叉树,判断是否他自己的镜 ...