Blue Bridge cup-print cross chart (text graphics class)

Source: Internet
Author: User

Print Cross Chart

Time limit: 1.0s memory limit: 256.0MBProblem description

Xiao Ming designed a cross-shaped logo for an institution (not the Red Cross), as shown below:

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

The other side also needs to be in the Computer DOS window in the form of characters to output the flag, and can control the number of layers.

Input format a positive integer n (n<30) indicates the number of layers required to print the graphic. The output format corresponds to this flag that encloses the number of layers. Example input 11 sample Output 1: $$$$$..
.. $...$..
$$$.$.$$$
$...$...$
$.$$$$$.$
$...$...$
$$$.$.$$$
.. $...$..
.. $$$$$.. Example input 23 sample Output 2: $$$$$$$$$$$$$..
.. $...........$..
$$$.$$$$$$$$$.$$$
$...$.......$...$
$.$$$.$$$$$.$$$.$
$.$...$...$...$.$
$.$.$$$.$.$$$.$.$
$.$.$...$...$.$.$
$.$.$.$$$$$.$.$.$
$.$.$...$...$.$.$
$.$.$$$.$.$$$.$.$
$.$...$...$...$.$
$.$$$.$$$$$.$$$.$
$...$.......$...$
$$$.$$$$$$$$$.$$$
.. $...........$..
.. $$$$$$$$$$$$$.. Tip Be careful to look at the sample, especially the number of periods and the output location.


Pretty simple, that's a little complicated.


AC code (explained in the code):


/*************************************************************************> File name:a.cpp> Author:zzuspy > Mail: [email protected] > Created time:2014 December 02 Tuesday 19:10 42 Seconds **************************************** /#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #define         LL long Long#define max3 (a,b,c) max (A,max (b,c)) #define MIN3 (a,b,c) min (a,min (b,c)) using namespace Std;char a[130][130];                       Up to 30, so big enough. int cen; Record the outer layer void init (char a[][130])//Initialize {for (int i=59; i<=63; i++) {for (int j=59; j<=63; J + +) {A[i][j] = '. ' ; }} for (int i=59, j=61; i<=63; i++) {A[i][j] = ' $ ';} for (int i=59, j=61; i<=63; i++) {A[j][i] = ' $ ';} cen= 0;}       void Fun (char a[][130])//Go outside with a layer {int min = 59-(cen+1) * *, max = 63+ (cen+1) * *; The minimum subscript and maximum subscript for the character after adding a layerT i=min; i<=max; i++) {A[i][min] = ' $ '; a[min][i] = ' $ '; A[i][max] = ' $ '; a[max][i] = ' $ ';} for (int i=min; i<=max; i++) {a[min+1][i] = '. '; A[max-1][i] = '. '; A[i][min+1] = '. '; A[i][max-1] = '. ';} A[MIN+1][MIN+2] = a[min+1][max-2] = ' $ '; a[min+2][min+1] = a[min+2][min+2] = a[min+2][max-1] = a[min+2][max-2] = ' $ '; a[max- 1][MIN+2] = a[max-1][max-2] = ' $ '; a[max-2][min+1] = a[max-2][min+2] = a[max-2][max-1] = a[max-2][max-2] = ' $ '; A[min][min] = A[min][max] = a[max][min] =a[max][max] = '. '; cen++;} int main () {int n;init (a); scanf ("%d", &n), int min = 59-n*2, max = 63+n*2;while (n--) {fun (a);} for (int i = min; i<=max; i++) {for (int j = min; j<=max; J + +) {printf ("%c", A[i][j]);} printf ("\ n");} return 0;}




Blue Bridge cup-print cross chart (text graphics class)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.