hdu1033

时间:2022-05-30
本文章向大家介绍hdu1033,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
#include<stdio.h>
#include<string.h>
const int MAXN=200;
char str[MAXN];
int main()
{
    int x,y;
    while(scanf("%s",&str)!=EOF)
    {
        int len=strlen(str);
        int x=310,y=420;
        int p=1;//标记走向,一开始是X轴正方向
        printf("300 420 moveton310 420 lineton");
        for(int i=0;i<len;i++)
        {
            switch(p)
            {
                case 1://X轴正方向
                     if(str[i]=='V') p=2,y+=10;
                     else p=-2,y-=10;
                     break;
                case 2://Y轴正方向
                     if(str[i]=='V') p=-1,x-=10;
                     else p=1,x+=10;
                     break;
                case -1://X轴负方向
                     if(str[i]=='V') p=-2,y-=10;
                     else p=2,y+=10;
                     break; 
                case -2:
                     if(str[i]=='V') p=1,x+=10;
                     else p=-1,x-=10;
                     break;
            }    
            printf("%d %d lineton",x,y);
        }    
        printf("strokenshowpagen");
 
    }    
    return 0;
    
}