HDU 2074 stacked baskets (Character Processing)

Source: Internet
Author: User
Stacked baskets

Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)

Total submission (s): 3272 accepted submission (s): 797

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.

 

Solution:

The question is not difficult to understand, but the answer is difficult to understand. It is not difficult to output such a format, but it will be PE or WA. The key is that the question does not indicate whether the four corners are spaces or Terminators. Is there an interval in each example?

1. The four corners are all spaces

2. Each example contains spaces only when the next example appears.

# Include <iostream> <br/> # include <iomanip> <br/> using namespace STD; <br/> int main () <br/> {<br/> int N, I, j, p, q = 0, L; char A, B, C, S [81] [81]; <br/> while (CIN> N> A> B) <br/> {<br/> for (I = 0; I <81; I ++) <br/> for (j = 0; j <81; j ++) <br/> S [I] [J] = '/0 '; <br/> L = N; <br/> If (n = 1) <br/>{< br/> If (q) <br/> cout <Endl; <br/> cout <A <Endl; <br/> continue; <br/>}< br/> If (q) <br/> cout <Endl; <br/> If (n/2) % 2 = 0) <br/> {<br /> C = A; <br/> A = B; <br/> B = C; <br/>}< br/> for (I = 0; I <n; I ++) <br/> for (j = 0; j <L; j ++) <br/>{< br/> if (I = J & I % 2 = 0) <br/>{< br/> for (P = I; P <L; P ++) <br/>{< br/> S [p] [J] = B; <br/> S [J] [p] = B; <br/> S [p] [n-1-j] = B; <br/> S [n-1-j] [p] = B; <br/>}< br/> L --; <br/>}< br/> else if (I = J & I % 2! = 0) <br/>{< br/> for (P = I; P <L; P ++) <br/>{< br/> S [p] [J] = A; <br/> S [J] [p] =; <br/> S [p] [n-1-j] = A; <br/> S [n-1-j] [p] = A; <br/>}< br/> L --; <br/>}< br/> I ++; <br/>}< br/> S [0] [0] = ''; s [n-1] [0] = ''; s [0] [n-1] =''; s [n-1] [n-1] = ''; <br/> for (I = 0; I <n; I ++) <br/> cout <s [I] <Endl; <br/> q ++; <br/>}< br/>}

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.