若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1013: Border

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,456

题目描述

You are to write a program that draws a border around a closed path into a bitmap, as displayed in the
following figure:

The path is closed and runs along the grid lines, i.e. between the squares of the grid. The path runs
counter-clockwise, so if following the path is considered as going ” forward ” , the border pixels are always
to the ” right ” of the path. The bitmap always covers 32 by 32 squares and has its lower left corner at (0,0).
You can safely assume that the path never touches the bounding rectangle of the bitmap and never
touches or crosses itself. Note that a bit gets set if it is on the outside of the area surrounded by the path
and if at least one of its edges belongs to the path, but not if only one of its corners is in the path. (A look
at the convex corners in the figure should clarify that statement.)

输入

The first line of the input contains the number of test cases in the file. Each test case that follows
consists of two lines. The first line of each case contains two integer numbers x and y specifying the
starting point of the path. The second line contains a string of variable length. Every letter in the string
symbolizes a move of length one along the grid. Only the letters `W' (“west''), `E' (“east''), `N' (“north''),
`S' (“south''), and `.' (“end of path'', no move) appear in the string. The end-of-path character (`.') is immediately followed by the end of the line.

输出

For each test case, output a line with the number of the case (`Bitmap #1', `Bitmap #2', etc.). For each
row of the bitmap from top to bottom, print a line where you print a character for every bit in that row
from left to right. Print an uppercase `X' for set bits and a period `.' for unset bits. Output a blank line
after each bitmap.

样例输入

1
2 1
EENNWNENWWWSSSES.

样例输出

Bitmap #1
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
.XXX............................
X...X...........................
X..X............................
X...X...........................
.X..X...........................
..XX............................

参考代码

#include<stdio.h>
#include<string.h>
int main() 
{
    int n;
    int total;
    int a=0,b=0;
    scanf("%d",&n);
    getchar();
    while(n>0) 
    {
        scanf("%d",&total);
        if(total%2!=0) 
        {
            a=0;
            b=0;
        } else if(total%4!=0) 
        {
            a=(total-2)/4+1;
            b=total/2;
        } else 
        {
            a=total/4;
            b=total/2;
        }
        printf("%d %dn",a,b);
        n--;
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip Dreams孤独患者 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist