1442: [Blue Bridge Cup] [2013 fourth Zhenti] Cross map print

Disclaimer: This article is a blogger original article, please include the URL bloggers reprint. https://blog.csdn.net/jiayizhenzhenyijia/article/details/88032739

Title Description

FIG printing papers previous cross  
time limit: 1.0s memory limit: 256.0MB 
     
problems described 
Xiaoming mechanism for a design of a cross-shaped logo (not ICRC ah), as follows:

 

 

..$$$$$$$$$$$$$..
..$...........$..
$$$.$$$$$$$$$.$$$
$...$.......$...$
$.$$$.$$$$$.$$$.$
$.$...$...$...$.$
$.$.$$$.$.$$$.$.$
$.$.$...$...$.$.$
$.$.$.$$$$$.$.$.$
$.$.$...$...$.$.$
$.$.$$$.$.$$$.$.$
$.$...$...$...$.$
$.$$$.$$$$$.$$$.$
$...$.......$...$
$$$.$$$$$$$$$.$$$
..$...........$..
..$$$$$$$$$$$$$..

 

 

The other side also needs to be output in the computer dos window in the form of the character of the mark, and can control any number of layers. 

Tip 
Please carefully observe the sample, with particular attention to the number and location of the output of the period. 

Entry

A positive integer n (n <30) represents the number of layers required for printing graphics.  

Export

Surrounding the flag corresponding to the number of layers.

Sample input

3  

Sample Output

..$$$$$$$$$$$$$..
..$...........$..
$$$.$$$$$$$$$.$$$
$...$.......$...$
$.$$$.$$$$$.$$$.$
$.$...$...$...$.$
$.$.$$$.$.$$$.$.$
$.$.$...$...$.$.$
$.$.$.$$$$$.$.$.$
$.$.$...$...$.$.$
$.$.$$$.$.$$$.$.$
$.$...$...$...$.$
$.$$$.$$$$$.$$$.$
$...$.......$...$
$$$.$$$$$$$$$.$$$
..$...........$..
..$$$$$$$$$$$$$.. 
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char map[1010][1010];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int i,j;
		int m=1+4*(n+1);
		for(i=1;i<=m;i++)
		{
			for(j=1;j<=m;j++)
				map[i][j]='.';
		}
		int sx,sy,ex,ey;
		sx=sy=1;
		ex=ey=m;
		while(n--)
		{
			sx+=2;
			ex-=2;
			for(i=sx;i<=ex;i++)
			{
				map[sy][i]='$';
				map[ey][i]='$';
			}
			sy+=2;
			ey-=2;
			for(i=sy;i<=ey;i++)
			{
				map[i][sx-2]='$';
				map[i][ex+2]='$';
			}
			map[sy-1][sx]='$';
			map[sy][sx-1]='$';
			map[sy-1][ex]='$';
			map[sy][ex+1]='$';
			map[ey+1][sx]='$';
			map[ey][sx-1]='$';
			map[ey+1][ex]='$';
			map[ey][ex+1]='$';
			map[sx][sy]=map[ex][ey]=map[sx][ey]=map[ex][sy]='$';
		}
		for(i=sy;i<=ey;i++)
		{
			map[i][sx+2]='$';
		}
		for(i=sx;i<=ex;i++)
		{
			map[sy+2][i]='$';
		}
		for(i=1;i<=m;i++)
		{
			for(j=1;j<=m;j++)
			{
				printf("%c",map[i][j]);
			}
			printf("\n");
		}
	}
}

 

Guess you like

Origin blog.csdn.net/jiayizhenzhenyijia/article/details/88032739
Recommended