2014 The fifth session of the Blue Bridge Cup test-C + + program Design Group B-print image

Source: Internet
Author: User
Tags ming

Title Description:
Title: Print Graphics

Xiao Ming found the shape and text in the Castle of Planet X:
Rank=3
  

Rank=5
  

Ran=6
  

Xiao Ming opened his brains, wrote the following program to achieve the graphic printing.

Program code:

#define N 70

void f (char a[][n], int rank, int row, int col)
{
Rank equals 1 of the situation
if (rank==1) {
A[row][col] = ' * ';
Return
}


int w = 1;
int i;
for (i=0; i<rank-1; i++) W *= 2;

 F (A, rank-1, row, COL+W/2); Blanks
F (A, rank-1, Row+w/2, col);
F (A, rank-1, ROW+W/2, col+w);
}

int main ()
{
Char A[n][n];
int i,j;

Initialize a character array to null
for (i=0;i<n;i++)
for (j=0;j<n;j++) a[i][j] = ";

Generate graphics
f (a,6,0,0);

Print out a graphic
for (i=0; i<n; i++) {
for (j=0; j<n; j + +) printf ("%c", A[i][j]);
printf ("\ n");
}

return 0;
}

2014 The fifth session of the Blue Bridge Cup test-C + + program Design Group B-print image

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.