杭电acm 1033题
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.
You may display such drawings with the gv PostScript interpreter, optionally after a conversion using the ps2ps utility.

AVV
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
/**********************************************
杭电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题的更多相关文章
- 杭电acm 1076题
水题,一个求闰年的题目,复习一下闰年的求法.... 1,如果能被4整除但不能被100整除的是闰年 2,能被400整除的是闰年 题目大意是:给定一个开始年份T以及一个正数N,要求求出从T开始,到了哪一年 ...
- 杭电acm 1037题
本题应该是迄今为止最为简单的一道题,只有一组输入,输出也简单.... /****************************************** 杭电acm 1037题 已AC ***** ...
- 杭电acm 1038题
本题比较简单,但是需要掌握几个小技巧,先上代码 /************************************* 杭电ACM 1038题,已AC ********************* ...
- 杭电acm 1049题
一道水题..... 大意是一条1inch的虫子在一个n inch的盒子的底部,有足够的能够每一分钟往上爬u inch,但是需要休息一分钟,这期间会往下掉d inch,虫子爬到盒子口即认为结束.要求计算 ...
- 杭电ACM刷题(1):1002,A + B Problem II 标签: acmc语言 2017-05-07 15:35 139人阅读 评
最近忙于考试复习,没有多少可供自己安排的时间,所以我利用复习之余的空闲时间去刷刷杭电acm的题目,也当对自己编程能力的锻炼吧. Problem Description I have a very si ...
- 杭电acm刷题顺序
最近兴趣来了,闲暇之余,回顾大学期间刷过的杭电acm那些入门级别的题,以此巩固基础知识! 以下参考刷题顺序,避免入坑 原文传送门:https://blog.csdn.net/liuqiyao_01/a ...
- 杭电acm 1015题
马上要找工作了,锻炼下自己的写程序能力,不多说,上代码 /********************杭电acm 1015 已AC 在这个程序里,使用穷举法来实现,但是输出顺序需要安装字典的最大 来输出 ...
- 杭电acm 1040题
本题是一个非常简单的升序排序题目,但那时在做的时候把题目看错了,导致花费了大量的时间来检查为什么WA,最后发现题目看错了..... /********************************* ...
- 杭电acm 1098题
Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice bu ...
随机推荐
- sublime text的pylinter插件设置pylint_rc后提示错误
sublime text插件pylinter提示错误 Warning: option include-ids is deprecated and ignored. 错误本身是Python的错误,这说明 ...
- CHAR,TCHAR,WCHAR 三者的区别与转换
#ifdef UNICODE typedef wchar_t TCHAR; #else typedef unsigned c ...
- 加深Java基础,做了20道题选择题!简答题没做
2015-03-16 17:13 269人阅读 评论(1) 收藏 举报 分类: 笔试(1) 版权声明:本文为博主原创文章,未经博主允许不得转载. 1,下列说法正确的是( A ) A )Jav ...
- POJ Layout
A - Layout Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit S ...
- 数据分析第二篇:matplotlib 常用的几个绘图方法
Matplotlib matplotlib是python的绘图库,使用它可以很方便的绘制出版质量级别的图形 matplotlib的基本功能 1.基本绘图 1.1 绘制坐标系中连续的线,设置线型/线宽/ ...
- 模拟C#的事件处理和属性语法糖
1. [代码]SharpEvent.hpp /* * SharpEvent.hpp * * Created on: 2014-5-5 * Author: leoking * Copyr ...
- angularjs 系列之$q和promise
还是同一个项目,在项目中,发现多个controller之内有一个共同的服务器请求,当时只是不断的重复使用,如今,现在项目结束,代码开始走向了优化迭代的阶段: 首先,我的思路是把这个共同的请求,从con ...
- C中malloc的使用(转)
malloc函数 原型:extern void *malloc(unsigned int num_bytes); 用法:#include <malloc.h> 功能:分配长度为num_b ...
- [转]关于新一轮QQ Tencent://Message 在线联系
关于在线QQ代码. 以前的QQ代码都需要添加好友. 现在的 首先是到http://wp.qq.com/生成你的QQ在线代码 很长的一段代码,并且每个QQ生成的sigT字符串都是不一样的.. 闲来无事, ...
- Operating System-Thread(1)What and Why Thread &&进程和线程的对比
开始线程(Thread)之旅,作为程序员,打交道更多的是线程,各种多线程程序,并行编程都是以线程为基础进行的.本文主要内容: What and Why Thread 进程和线程的对比 一.What a ...