Hdu2074 stacked baskets

Source: Internet
Author: User
Stacked baskets

Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 12124 accepted submission (s): 3123


When the Problem description is required, the baskets with different sizes are stacked so that the colors of the baskets are staggered from the top down. This job is now going to be done by the computer. It depends on you.


 

The input is a three-character pair, which is, the size of the outer basket is n (n is an odd integer that satisfies 0 <n <80), the central color character, and the color character of the outer basket, both are ASCII visible characters;


 

Output outputs a basket pattern stacked together. The central color and the color characters of the outer basket are staggered from the inner layer. When multiple baskets are stacked, the corners of the outermost basket are always polished. The stacked baskets and stacked baskets should be separated by one line.


 

Sample Input
11 B A5 @ W
 


 

Sample output
 AAAAAAAAA ABBBBBBBBBAABAAAAAAABAABABBBBBABAABABAAABABAABABABABABAABABAAABABAABABBBBBABAABAAAAAAABAABBBBBBBBBA AAAAAAAAA  @@@ @[email protected]@[email protected]@@[email protected] @@@ 

 

This question must be very careful and pay attention to special data, such as when n = 1.

#include <stdio.h>#define maxn 82char map[maxn][maxn];int main(){int n, i, j, k, sign, len, ii, cas = 1;char ch[2];while(scanf("%d %c %c", &n, &ch[0], &ch[1]) != EOF){sign = ((n / 2) & 1);for(i = 0; i < n / 2; ++i, sign = !sign){len = n - i * 2;k = len - 1; j = i;while(k--) map[i][j++] = ch[sign];k = len - 1; ii = i;while(k--) map[ii++][j] = ch[sign];k = len - 1;while(k--) map[ii][j--] = ch[sign];k = len - 1;while(k--) map[ii--][j] = ch[sign];}map[n/2][n/2] = ch[0];if(n != 1)  map[0][0] = map[0][n-1] = map[n-1][0] = map[n-1][n-1] = ' ';if(cas++ != 1) printf("\n");for(i = 0; i < n; ++i){map[i][n] = '\0';printf("%s\n", map[i]);}}return 0;}


 

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.