Mahjong table draw (Beijing Institute of Technology school program of 2019, School of Computer Design Methods and Practices)

Mahjong table draw

Rima annual contest is starting now, you bird disabilities quitting brave victory. In addition to the pinnacle of the game exciting showdown on everyone's outside, in order to increase the viewing of the game, but also a nice table, then you help the designer to draw a table it.

In a contest as long w, wide draw is on the table h, in order to facilitate the description, we carried out the following definitions:

We Desk w × h can be divided into squares, each square size is 1 × 1.
We define the grid coordinates of its center point.
Thus, for each center point (x, y), the range of the actual grid x'∈ [x-0.5, x + 0.5], y'∈ [y-0.5, y + 0.5].
Point (0,0) center in the upper left corner of the grid.
Point (w-1,0) in the center of the lower left corner of the grid.
Point (0, h-1) at the center of the upper right corner of the grid.
Point (w-1, h-1 ) at the center of the lower right corner of the grid.
Designers circle and a square, a circle, like paste on the grid logo mahjong, specifically:

For the circle C, given its center coordinates (xC, yC) and radius r. If and only if the center point of the lattice to a distance not exceeding the radius r, the grid will be labeled mahjong logo. As shown below.
For squares, which gives the two vertex coordinates (x1, y1) of an edge, (x2, y2) is clockwise. If and only if the center point of the grid in the rectangle on the edge or inside when the grid will be labeled mahjong logo. Given axis and parallel to the edges to ensure. As shown below.

  •  

Now to the length and width, as well as information circular and rectangular table you this, please help you draw out the entire table. If no logo stickers mahjong, please output '∖ ', otherwise the output of' / '(without the quotes). You should ensure that the output of the upper left corner table of the first character in your output.

input

A total of three lines of input data, a first row comprises two integers w, h (10≤w, h≤200), mahjong table showing length and width.

The second row includes three integers xC, yC, r (-100≤xC, yC≤200,0 <r≤200), represented by the circle center and radius.

The third row includes four integers x1, y1, x2, y2 (-100≤x1, y1, x2, y2≤200), a rectangle representing the two endpoints.

output

The output common line w, h characters per line, as '∖' or '/' (without the quotes).

input

11 11
5 5 5
4 3 4 7

output

\\\\\/\\\\\
\\///////\\
\/////////\
\/////////\
\/////////\
///////////
\/////////\
\/////////\
\/////////\
\\///////\\
\\\\\/\\\\\

Note: For a square, two given vertex coordinates (x1, y1) of which one side, (x2, y2) is clockwise. In four cases we need to talk about. Hang QAQ

#include<stdio.h>
#include<iostream>
#include<algorithm> 
using namespace std;
char mp[250][250];
int x,y,r;

int  ok1(int tx,int ty){
    if((tx-(x))*(tx-(x))+(ty-(y))*(ty-(y))<=r*r){
        return 1;
    }else{
        return 0;
    }
}
int main(){
    int w,h;
    
    int x1,y1,x2,y2;
    scanf("%d%d",&w,&h);
    scanf("%d%d%d",&x,&y,&r);
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    for(int i=0;i<=w;i++)
        for(int j=0;j<=h;j++)
            mp[i][j]='\\';
    int flag=0;
    int a1,a2,b1,b2;
    if(x1==x2){
        int dis=abs(y1-y2);
        if(y1<y2){
            a1=x1;b1=y1;
            a2=x1+dis;b2=y2;
        }else{
            a1=x2-dis;b1=y2;
            a2=x1;b2=y1;
        }
    }
    if(y1==y2){
        int dis=abs(x1-x2);
        if(x1<x2){
            a1=x1;b1=y1-dis;
            a2=x2;b2=y2;
        }else{
            a1=x2;b1=y2;
            a2=x1;b2=y1+dis;
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            int xx=i;
            int yy=j;
            if(ok1(xx,yy)){
                mp[i][j]='/';
            } 
            if(i>=a1&&i<=a2&&j>=b1&&j<=b2){
                mp[i][j]='/';
            }
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            printf("%c",mp[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

 

AC Code:

 

Guess you like

Origin www.cnblogs.com/pengge666/p/11494088.html