HDU 2074 stacked baskets (number theory)

Source: Internet
Author: User
When the HDU 2074 stacked basket Problem description is required, the baskets with different sizes are stacked to make the colors of the baskets staggered from the top to the bottom. 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 input11 B A5 @ w

 

Sample output aaaaaaaaa abbbbbbbbbaabaaaaaaabaababbbbbabaababaaababaabababababaababaaababaababbbbbabaabaaaaaaabaabbbbbbbbba aaaaaaa @ WWW @ w @ WWW @@@@

 

C ++CodeAs follows:

# Include <iostream>
Using namespace STD;
Int main ()
{
Char a, B, T;
Int N, I, j;
Char STR [90] [90];
Int r = 0;
While (CIN> N> A> B)
{
If (r ++)
Cout <Endl;
If (n = 1)
{
Cout <A <Endl;
Continue;
}
If (N % 4 = 1)
T = A, A = B, B = T;
For (I = 0; I <n; I ++)
STR [0] [I] = B;
For (I = 1; I <= n/2; I ++)
{
Memcpy (STR [I], STR [I-1], sizeof (STR [I-1]);
For (j = I; j <n-I; j ++)
If (I % 2 = 0)
STR [I] [J] = B;
Else
STR [I] [J] =;
}
STR [0] [0] = STR [0] [n-1] = '';
For (I = 0; I <= n/2; I ++)
{
For (j = 0; j <n; j ++)
{
Cout <STR [I] [J];
}
Cout <Endl;
}
For (I = n/2-1; I> = 0; I --)
{
For (j = 0; j <n; j ++)
{
Cout <STR [I] [J];
}
Cout <Endl;
}
}
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.