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