HDU2074 Stacking Basket (simulation problem)

Source: Internet
Author: User

problem Description
http://acm.hdu.edu.cn/showproblem.php?pid=2074
when needed, the size of a circle of the basket stacked up, so that from the top down when looking at the side baskets of color staggered. The work now needs to be done by the computer, which depends on you.
Inputinput is a ternary group, respectively, the outer basket size n (n to meet the 0<n<80 of odd integers), Central color characters, outer basket color characters, both are ASCII visible characters; Outputoutput Stacked basket pattern, center suit and outer basket color characters from the inner layer staggered from the overlapping, multi-basket stack, the outer corner of the basket is always polished off. There should be a line between the stacked basket and the stacking basket.  Sample Input
B A5 @ W
 Sample Output
AAAAAAAAA Abbbbbbbbbaabaaaaaaabaababbbbbabaababaaababaabababababaababaaababaababbbbbabaabaaaaaaabaabbbbbbbbba AAAAAAAAA @@ @ @[email protected]@[email protected]@@[email protected] @@@ topic Analysis: The main attention to a variety of traps, 1, note the format four small corner 2, must start from the middle of the simulation 3, the most helpless format, n=1, And after the last output there are no spaces. Note that this will be AC. AC Code:
/** * @xiaoran * simulation, must start from the center */#include <iostream> #include <cstdio> #include <map> #include <cstring > #include <string> #include <algorithm> #include <queue> #include <vector> #include < stack> #include <cstdlib> #include <cctype> #include <cmath> #define LL long longusing namespace std;    Char S[105][105];int main () {int i,j,n,ok,flag=0; char A, B; while (cin>>n>>a>>b) {if (flag) cout<<endl;//Note format if (n==1) {cout<<a&lt            ;<endl;            flag=1;        Continue } I=N/2;        ok=0; while (I!=-1) {if (ok==0) {//center suit for (j=i;j<n-i;j++) s[i][j]=a;//first row for (j=i;j&lt ; n-i;j++) s[n-i-1][j]=a;//last line for (j=i;j<n-i;j++) s[j][i]=a;//first column for (j=i;j<n-i;j++) s [j]            [n-i-1]=a;//last column ok=1; }else{for (j=i;j<n-i;j++) s[i][j]=b;//first line for (j=i;j<n-i;j+ +) s[n-i-1][j]=b;//last line for (j=i;j<n-i;j++) s[j][i]=b;//first column for (j=i;j<n-i;j++) s[j][n-            i-1]=b;//the last column of ok=0;        }-I.; } for (int i=0;i<n;i++) {for (int j=0;j<n;j++) {if ((i==0&&j==0) | | | (i==n-1&&j==0) | | (j==n-1&&i==0) | | (j==n-1&&i==n-1))                cout<< "";            else cout<<s[i][j];        } cout<<endl;    } flag=1; }return 0;}



HDU2074 Stacking Basket (simulation problem)

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.