您的位置:首页 > 其它

排版题 3

2016-01-31 15:04 429 查看
/*

题目1161 repeater

题目描述:

Harmony is indispensible in our daily life and no one can live without it----may be Facer is the only exception. 

One day it is rumored that repeat painting will create harmony and then hundreds of people started their endless drawing. 

Their paintings were based on a small template and a simple method of duplicating. Though Facer can easily imagine the 

style of the whole picture,but he cannot find the essential harmony. Now you need to help Facer by showing the picture 

on computer.You will be given a template containing only one kind of character and spaces, and the template shows 

how the endless picture is created----use the characters as basic elements and put them in the right position to form a bigger template,

 and then repeat and repeat doing that. Here is an example.

# #

 #      <-template

# #

So the Level 1 picture will be

# #

 #

# #

Level 2 picture will be

# #     # #

 #         #

# #     # #

     # #   

      #    

     # #   

# #    # #

 #        # 

# #    # #

输入:

The input contains multiple test cases.

The first line of each case is an integer N, representing the size of the template is N*N (N could only be 3, 4 or 5).

Next N lines describe the template.

The following line contains an integer Q, which is the Scale Level of the picture.

Input is ended with a case of N=0.

It is guaranteed that the size of one picture will not exceed 3000*3000.

输出:

For each test case, just print the Level Q picture by using the given template.

样例输入:

3

# #

 # 

# #

1

3

# #

 # 

# #

3

4

 OO 

O  O

O  O

 OO 

2

0

样例输出:

# #

 # 

# #

# #   # #         # #   # #

 #     #           #     # 

# #   # #         # #   # #

   # #               # #   

    #                 #    

   # #               # #   

# #   # #         # #   # #

 #     #           #     # 

# #   # #         # #   # #

         # #   # #         

          #     #          

         # #   # #         

            # #            

             #             

            # #            

         # #   # #         

          #     #          

         # #   # #         

# #   # #         # #   # #

 #     #           #     # 

# #   # #         # #   # #

   # #               # #   

    #                 #    

   # #               # #   

# #   # #         # #   # #

 #     #           #     # 

# #   # #         # #   # #

     OO  OO     

    O  OO  O    

    O  OO  O    

     OO  OO     

 OO          OO 

O  O        O  O

O  O        O  O

 OO          OO 

 OO          OO 

O  O        O  O

O  O        O  O

 OO          OO 

     OO  OO     

    O  OO  O    

    O  OO  O    

     OO  OO     

*/

#include<stdio.h>  

#include<math.h>  

int n,q;  

char a[10][10],s[3005][3005];  

void input()  

{  

    int i,j;  

    getchar();  

    for(i=0;i<n;i++)  

    {  

        for(j=0;j<n;j++)  

            scanf("%c",&a[i][j]);  

        getchar();  

    }  

    scanf("%d",&q);  

}  

void print(int x,int y,int p)  

{  

    int i,j;  

    int h,k;  

    if(p==1)  

    {  

        for(i=0;i<n;i++)  

            for(j=0;j<n;j++)  

                s[x+i][y+j]=a[i][j];  

    }  

    else  

    {  

        for(i=0;i<n;i++)  

        {  

            for(j=0;j<n;j++)  

            {  

                if(a[i][j]!=' ')  

                {  

                    print(x+i*pow(n*1.0,(p-1)*1.0),y+j*pow(n*1.0,(p-1)*1.0),p-1);  

                }  

                else  

                {  

                    for(h=x+i*pow(n*1.0,(p-1)*1.0);h<x+(i+1)*pow(n*1.0,(p-1)*1.0);h++)  

                        for(k=y+j*pow(n*1.0,(p-1)*1.0);k<y+(j+1)*pow(n*1.0,(p-1)*1.0);k++)  

                            s[h][k]=' ';  

                }  

            }  

        }  

    }  

}  

int main()  

{  

    int i,j;  

    while(scanf("%d",&n)!=EOF&&n)  

    {  

        input();  

        print(0,0,q);  

        for(i=0;i<pow(n*1.0,q*1.0);i++)  

        {  

            for(j=0;j<pow(n*1.0,q*1.0);j++)  

                printf("%c",s[i][j]);  

            printf("\n");  

        }  

    }  

    return 0;  

}  

   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: