Hduj 2074 stacked basket Simulation

Source: Internet
Author: User

Stacked baskets Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 12017 accepted submission (s): 3074


When Problem description is required, the baskets with different sizes are stacked so that the colors of the baskets are staggered from the top down. It's up to you to get the computer done.
The input is a triple, each of which is, the size of the outer basket is n (n is an odd integer that meets the requirements of 0 <n <80), the central color character, 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] @@@ 
 



#include<iostream>#include<cstring>using namespace std;int main(){int n;char c1,c2,k=0;while(cin>>n){cin>>c1>>c2;int i,j,m,p,q;char str[81][81];memset(str,0,sizeof(str));p=0;q=n-1;m=(n-1)/2;if(k++)   cout<<endl;if(n==1)cout<<c1<<endl;else{while(m<=q){if((q-p+1)%4==3){for(i=p;i<=q;i++)for(j=p;j<=q;j++)str[i][j]=c2;p++;q--;}else{for(i=p;i<=q;i++)for(j=p;j<=q;j++)str[i][j]=c1;p++;q--;}}str[0][0]=str[n-1][0]=str[0][n-1]=str[n-1][n-1]=' ';for(i=0;i<n;i++)cout<<str[i]<<endl;}}return 0;}


Hduj 2074 stacked basket Simulation

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.