九度 oj 题目1161:Repeater

62 篇文章 0 订阅

http://ac.jobdu.com/problem.php?pid=1161


#include <stdio.h>

static int N,Q; 
static char Map[3001][3001];
static char Template[6][6];
int myPow(int n,int q){ 
    int m = 1;
    while(q--){ 
    m*=n;     
    } 
    return m;
} 
void make_map(int left,int up,int right,int down,int q,bool mark){ 
    //printf("q:%d\n",q); 
    if(q == 1){ 
        for (int i = up; i < down ; ++i) { 
            for (int j = left ; j < right ; j++) { 
                 Map[i][j]= mark? Template[i-up][j-left]:' '; 
            }  
            //printf("\n"); 
        }  
        return ;
    }   
    q--;
    for (int i = 0; i < N; ++i) { 
        for (int j = 0; j < N; ++j) { 
                make_map(left+j*myPow(N,q),up+i*myPow(N,q),left+(j+1)*myPow(N,q),up+(i+1)*myPow(N,q),q,mark&&Template[i][j]!=' '); 
        }  
    } 
} 

int main(){ 
    //freopen("in/1161.in","r",stdin); 
    //freopen("out/1161.out","w",stdout); 

    while( scanf("%d",&N) && N!=0 ){
        getchar();
        for (int i = 0; i < N; ++i) { 
            for (int j = 0;  j< N; j++) { 
                scanf("%c",&Template[i][j]);   
            } 
           getchar(); 
        }  

        scanf("%d",&Q); 
        getchar();
        //if(--ncase == 0) break;
        make_map(0,0,myPow(N,Q),myPow(N,Q),Q,true);
        for (int i = 0; i < myPow(N,Q); ++i) { 
            for (int j = 0;  j< myPow(N,Q); j++) { 
                printf("%c",Map[i][j]);  
            } 
            printf("\n"); 
        } 
    }  
}  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值