排版题 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;
}
题目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;
}
相关文章推荐
- hdu1213 How Many Tables
- 数据结构:JavaScript实现链表
- HDU1754线段树
- Python注释
- ajax与Jquery中的Ajax
- Java读取properties文件中文乱码问题解决
- C语言小结之链表
- 9. Swift 中的函数
- OpenWRT开发之——研究包的Makefile
- android-Implementing Descendant Navigation,Notifying the User
- linux内核输入子系统分析
- 一组常用的弹出窗口用法
- 从头到尾彻底理解KMP
- ajax SpringMVC如何返回json
- HDU1495 非常可乐
- WEB SQL Database 随机读取函数
- fedora 21 + win8 开机启动项的顺序设为默认启动win8
- 【校内互测】回文词
- C++的map与hash_map
- startActivity()和onActivityResult() 返回上一个Activity并传值