zoukankan      html  css  js  c++  java
  • POJ 2556 Edge

    题意:好久没做题,毕业之前心血来潮做几个题,随便选了个水题,就是2556,结果恶心了,题目看了好几遍,愣是没懂,看了看例子的图像,才知道input,output是什么意思。大致是A是顺时针拐,V是逆时针拐,最后输出路径。第一次连题目都没看懂AC了。

    #include <iostream>
    #include
    <cstdio>
    #include
    <algorithm>
    #include
    <memory.h>
    #include
    <cmath>
    #include
    <bitset>
    #include
    <queue>
    #include
    <vector>
    using namespace std;

    const int MAXN = 1010;
    const int INF = 0x4ffffff;

    #define CLR(x,y) memset(x,y,sizeof(x))
    #define ABS(x) ((x)>0?(x):-(x))

    char str[300];
    int dir[4][2] = {{10,0},{0,-10},{-10,0},{0,10}};


    int work()
    {
    int i,j,tmp,k;
    int n = strlen(str);
    int cur = 0;
    int x = 300;
    int y = 420;
    printf(
    "%d %d moveto\n",x,y);
    x
    += 10;
    printf(
    "%d %d lineto\n",x,y);

    for(i = 0; i < n; ++i)
    {
    if(str[i] == 'A')
    cur
    = ((++cur)&3);
    else if(str[i] == 'V')
    cur
    = ((--cur+4)&3);
    x
    += dir[cur][0];
    y
    += dir[cur][1];
    printf(
    "%d %d lineto\n",x,y);
    }
    printf(
    "stroke\nshowpage\n");
    return 0;
    }
    int main()
    {
    while(scanf("%s",str) != EOF)
    {
    work();
    }
    return 0;
    }

  • 相关阅读:
    启动容器失败:endpoint with name cop already exists in network host.
    docker定时任务执行脚本报错:the input device is not a TTY
    期末总结
    云图学习
    豆瓣top250
    爬取学习
    爬取图片
    爬取学习bs4
    爬取学习 屠戮盗版天堂
    爬取学习
  • 原文地址:https://www.cnblogs.com/lvpengms/p/2064294.html
Copyright © 2011-2022 走看看