博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
模版生成图片第七题
阅读量:3937 次
发布时间:2019-05-23

本文共 3550 字,大约阅读时间需要 11 分钟。

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 NN (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# # # # #13# # # # #34 OO O  OO  O OO 20

输出

# # # # ## #   # #         # #   # # #     #           #     # # #   # #         # #   # #   # #               # #       #                 #       # #               # #   # #   # #         # #   # # #     #           #     # # #   # #         # #   # #         # #   # #                   #     #                   # #   # #                     # #                         #                         # #                     # #   # #                   #     #                   # #   # #         # #   # #         # #   # # #     #           #     # # #   # #         # #   # #   # #               # #       #                 #       # #               # #   # #   # #         # #   # # #     #           #     # # #   # #         # #   # #     OO  OO         O  OO  O        O  OO  O         OO  OO      OO          OO O  O        O  OO  O        O  O OO          OO  OO          OO O  O        O  OO  O        O  O OO          OO      OO  OO         O  OO  O        O  OO  O         OO  OO

解决代码:

#include
#include
#include
#include
using namespace std; char templat [6][6]; //初始模版: char m2[3000][3000];// new template char result[3000][3000]; int len; // new the size of matrix int n,q; // input n and q levelvoid update(int x,int y,bool flag) { // len 应该是此时(模版)的大小 for (int i = 0;i < len; i++) { for (int j = 0; j < len; j++) { if (flag) result [x+i][y+j] = m2[i][j]; // 每次更新一个模版大小的图形 else result [x+i][y+j] = ' '; } } }int main(){ while(scanf("%d",&n)){ // input and output is not in same buffer so,every time you can output the result array; if(0==n) break; //2.前面的scanf()在读取输入时会在缓冲区中留下一个字符'\n'(输入完s[i]的值后按回车键所致), //所以如果不在此加一个getchar()把这个回车符取走的话,gets()就不会等待从键盘键入字符, //而是会直接取走这个“无用的”回车符,从而导致读取有误; getchar(); // take the \n for(int i=0;i

总结:

  1. 先构造结果的matrix 然后再输出
  2. 每一个存在换成模版
  3. 注意每个level的 判断
  4. c++基础知识,从命令行读入一段字符串。

转载地址:http://gjywi.baihongyu.com/

你可能感兴趣的文章
how to move pivot to origin
查看>>
Optimizate objective function in matrix
查看>>
Convert polygon faces to triangles or quadrangles
查看>>
How do I divide matrix elements by column sums in MATLAB?
查看>>
read obj in matlab
查看>>
find out the neighbour matrix of a mesh
查看>>
Operators and special characters in matlab
查看>>
As-Conformal-As-Possible Surface Registration
查看>>
qmake Variable Reference
查看>>
Lesson 2 Gradient Desent
查看>>
find border vertex
查看>>
matlab sliced variable
查看>>
create symbolic array
查看>>
TAUCS库的编译(vs2010)
查看>>
color vector using in plotting example points and lines between corresponding vertices
查看>>
mex 里面调用matlab函数
查看>>
matlab中cuda编程中分配grid和block dimension的时候的注意事项
查看>>
GPU CUDA and MEX Programming
查看>>
arrayfun用法
查看>>
矩阵积分
查看>>