首页 > 试题广场 >

Repeater

[编程题]Repeater
  • 热度指数:9035 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
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.
示例1

输入

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     
头像 Caiguu
发表于 2021-06-20 17:47:40
复读是坠吊的!(x 题目大意 根据模板产生不同层数的图形 解题思路 可以考虑,大的绘图由小的模块组成,每个小的模块都可以再次拆分,直到每个小的模块只剩下单个字符,因此考虑使用递归。递归考虑为给定当前的模块的起始绘图区域,交给下一个递归去做。 递归表达式 进行递归之前,需要明确需要使用的变量。 解释 展开全文
头像 DioDid
发表于 2022-01-14 21:11:34
法1: 我的思路及其简单 实现及其复杂 运行有5ms 主要思路是首先将模板矩阵,读入一个5*5的Temp矩阵中 计算出将要打印内容的矩阵大小 随后在足够大的ForPrint矩阵中,逐个位置遍历,确定其符号 是空格还是其他 确定符号的方法是: 考虑最外层,可以看做是次外层,按照原来模板的状态逐个对应的 展开全文
头像 flyflyfly00
发表于 2021-03-06 16:43:31
#include<iostream> #include<cstdio> #include<math.h> #include<string> using namespace std; char templat [6][6]; //初始模版: char 展开全文
头像 Taitres
发表于 2021-05-11 11:07:22
1.题目分析 输入:要求第一行为N,使基本图形为N*N(N只能是3,4,5),第二行为基本图形,第三行为重复的比例级别。 用一个二维数组来存储基本图形,之后遍历图形,level从0开始,遇到字符就用基本图形去填充结果,遇到空格就用len*len个空格(len与=n的level次方)去填充,循环一次更 展开全文
头像 Yy七灵微
发表于 2024-05-11 02:28:00
import sys template_ = [] def big(n, t, result): # 原模版长度,模版,结果 new_num = len(result) * n # 新画布行数 new_result = [[] for i in range(new_num) 展开全文
头像 福音骑士
发表于 2023-04-29 21:29:55
#include <iostream> using namespace std; char ori[10][10]; char ans[2][3000+10][3000+10]; int n, rows; //rows为当前ans中有效的行列数 void nextScale(int ol 展开全文
头像 zoey447
发表于 2022-01-23 21:46:26
">#include<string> #include<math.h> using namespace std; char result[3000][3000]; // temple为模板,n为模板大小,scale为规模,pos:起始行数 void show(char t 展开全文
头像 糖分椰蓉糯米糍
发表于 2022-01-22 17:46:22
详细思路: https://blog.csdn.net/LOG_IN_ME/article/details/122645786?spm=1001.2014.3001.5502 递归,关键是每层递归记住并计算当前层的元素坐标,递归终止时便结算该元素的最终位置。 #include<bits/std 展开全文
头像 BryceP
发表于 2023-02-14 00:41:33
/* 习题2-4 Repeater(北京大学复试上机题) 题目描述: 输入: 输出: 分析:利用数组进行排版 提交网址:http://t.cn/E9jcaVb */ #include <iostream> #include <cstdio> using namespace s 展开全文
头像 废柴逆天从copy开始
发表于 2024-01-17 20:47:08
#include <stdio.h> #include <math.h> int N, Q; // N 为模板边长,Q 为边长放大倍率 // 存储模板 char t[6][6]; // 存储输出图形,行多 1 用于存储结束符号 char output[3000][30 展开全文

问题信息

难度:
53条回答 8800浏览

热门推荐

通过挑战的用户

查看代码