九度 位置

题目1161:Repeater

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:682

解决:225

题目描述:

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<stdlib.h>
#include<math.h>
#include<string.h>
void print(int x,int y,int n,int lev,char shape[][3001],int n1,char result[][3001])//起始位置,需要打印尺寸,和最初形状矩阵 最初尺寸
{
	if(lev==1)
	{
		for(int i=x,i1=0;i<x+n1;i++,i1++)
		{
			for(int j1=0,j=y;j<y+n1;j++,j1++)
			{
				result[i][j]=shape[i1][j1];
			}
		}
	}
	else//在每一个非空位置打印前一个等级图形
	{
		for(int i=0;i<n1;i++)
		{
			for(int j=0;j<n1;j++)
			{
				if(shape[i][j]!=' ')
				{
					print(x+i*(n/n1),y+j*(n/n1),n/n1,lev-1,shape,n1,result);
				}
			}
		}
	}
}
char result[3001][3001];
char buf[3001][3001];
int main()
{
	int size1;
	int size;
	int level;
	while(scanf("%d",&size1)!=EOF)
	{
	    for(int i=0;i<3001;i++)
        {
            for(int j=0;j<3001;j++)
            {
                result[i][j]=' ';
                buf[i][j]=' ';
            }
        }
	    getchar();
		for(int i=0;i<size1;i++)
		{


			for(int j=0;j<size1;j++)
			{


				scanf("%c",&buf[i][j]);
			}
			getchar();
		}
		scanf("%d",&level);
		size=pow(size1,level);
		print(0,0,size,level,buf,size1,result);
		for(int i=0;i<size;i++)
        {
            for(int j=0;j<size;j++)
            {
                printf("%c",result[i][j]);
            }
            printf("\n");
        }
	}
}
http://blog.csdn.net/j597960549/article/details/20560863这个写得不错,两个缓冲区的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值