题目1161:Repeater 题目链接:http://ac.jobdu.com/problem.php?pid=1161

具体分析:https://github.com/zpfbuaa/JobduInCPlusPlus

注意找到规律,因为打印图形都是规律性的!!!

这里需要不断对二维数组进行更新操作

每次都是幂乘结果!

然后进行循环

这个循环就是幂乘次数!

2017年07月26日23:06:12

参考代码:

//
// 1161 Repeater.cpp
// oj
//
// Created by PengFei_Zheng on 05/04/2017.
// Copyright © 2017 PengFei_Zheng. All rights reserved.
// #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <stdlib.h>
#include <cmath> using namespace std; int n,q;
char buf[][];
char sample[][];
char board[][]; void init(int a, int b, int n){
for(int i = ; i < n ; i ++){
for(int j = ; j < n ; j ++){
buf[a * n + i][b * n + j]=' ';
}
}
} void copy(int a, int b, int n){
for(int i = ; i < n ; i ++){
for(int j = ; j < n ; j++){
buf[a * n + i][b * n + j] = sample[i][j];
}
}
} void update(int n){
for(int i = ; i < n ; i ++){
for(int j = ; j < n ; j ++){
sample[i][j]=buf[i][j];
}
}
} int main(){
while(scanf("%d",&n)!=EOF&&n!=){
getchar();
for(int i = ; i < n ; i ++){
for(int j = ; j < n ; j ++){
scanf("%c",&buf[i][j]);
board[i][j]=buf[i][j];
}
getchar();
}
scanf("%d",&q);
int size = n ;
for(int k = ; k <= q ; k++){
update(size);
for(int i = ; i < n ; i++){
for(int j = ; j < n ; j++){
if(board[i][j]==' ')
init(i,j,size);
else
copy(i,j,size);
}
}
size = pow(n,k);
}
for(int i = ; i < size ; i ++){
for(int j = ; j < size ; j ++){
printf("%c",buf[i][j]);
}
cout<<endl;
}
}
return ;
} /**************************************************************
Problem: 1161
User: zpfbuaa
Language: C++
Result: Accepted
Time:210 ms
Memory:19200 kb
****************************************************************/

题目1161:Repeater(规律输出图形)的更多相关文章

  1. For嵌套输出图形

    /*输出此图形    *   * *  * * * * * * ** * * * *  * * * *   * * *   * *     *解析:可以把此图形看成两部分----*---* *--* ...

  2. for语句输出图形

    一.输出以下图形 ******************************** 用for...for...嵌套循环,内循环控制每一行的个数(即列数),外循环控制行数 class ForDraw { ...

  3. LeetCode 38 Count and Say(字符串规律输出)

    题目链接:https://leetcode.com/problems/count-and-say/?tab=Description   1—>11—>21—>1211—>111 ...

  4. 树 List Leaves 【用数组模拟了树状结构建树+搜索叶子节点+按照特殊规律输出每个叶子节点】

    Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. I ...

  5. 利用for循环的嵌套输出图形--课后作业

    for (int i = 1; i <= 8; i++) { int a, b; for (a = 1; a < i; a++) Console.Write(" "); ...

  6. JAVA输出图形(网上找的)

    public class TuXing { public static void main(String[] args) { int i, j, k; for (i = 1; i <= 5; i ...

  7. Java实现 蓝桥杯 算法提高 套正方形(暴力)

    试题 算法提高 套正方形 问题描述 给定正方形边长width,如图按规律输出层层嵌套的正方形图形. 注意,为让选手方便观看,下图和样例输出均使用""代替空格,请选手输出的时候使用空 ...

  8. Java实现 蓝桥杯 算法提高 套正方形

    试题 算法提高 套正方形 资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述 给定正方形边长width,如图按规律输出层层嵌套的正方形图形. 注意,为让选手方便观看,下图和样例输出均使用 ...

  9. matplotlib简介-高质量图形输出

    Matplotlib 是一个用来绘制二维图形的 Python 模块,它克隆了许多 Matlab 中的函数, 用以帮助 Python 用户轻松获得高质量(达到出版水平)的二维图形. 文章来源:http: ...

随机推荐

  1. js 按键

    原文:https://www.cnblogs.com/lunlunshiwo/p/8705856.html 上周临近周末休息的时候,一个同事跑过来了,对我说:“阿伦啊,有一个页面出问题了,火狐浏览器所 ...

  2. Publish/Subscribe Model——Notification chain——观察者模式

    内核中用的很多,整理时间子系统的时候又遇到了notification mechanism,因此做次记录: 参考:1.http://msdn.microsoft.com/en-us/library/ff ...

  3. 安装oh my zsh和git插件

    http://macshuo.com/?p=676   --安装oh my zsh http://www.jianshu.com/p/9189eac3e52d https://github.com/r ...

  4. 解决计算机改名无法连接TFS的问题

    闲着没事改了下计算机名字,结果造成TFS无法连接. 报错讯息如下: ---------------------------Microsoft Visual Studio---------------- ...

  5. js将json数据以csv格式下载

    摘要: 最近有一个非项目的小需求,就是将项目开发分工文件化,方便后期管理维护.但是开发时,分工安排都是以json格式记录的,所以就做了一个将json数据以csv格式下载到本地. 代码: <!DO ...

  6. 关于python 的空的__init__.py文件的作用,可不可以删除,到底有没有用?

    0.声明,本篇只讨论空__init__.py文件的情况,不顾前提非得说__init__.py文件里面也可以写东西的不在此讨论了范围之内,重点是个"空"字. 1.很多地方的文件夹都有 ...

  7. 禁止requests请求https的提示InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more

     提示这个 InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from ...

  8. [原]巧用RenderTexture

    郑重声明:转载请注明出处 U_探索 本文诞生于面试过程中这道题:NGUI如何制作3D角色的显示.(大概是这样)  呵呵 没事出去面试面试,考核考核自己也是一种不错的方式哦!不过现在u3d面试,貌似比以 ...

  9. SpringMVC由浅入深day01_5注解的处理器映射器和适配器

    5 注解的处理器映射器和适配器 在spring3.1之前使用org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandle ...

  10. 找不同diff-打补丁patch

    Q:为什么要找不同,为什么要打补丁? A: 在Linux应用中,作为DBA,我们知道MySQL跑在Linux系统之上,数据库最重要的追求就是性能,“稳”是重中之重,所以不能动不动就是换系统或是换这换那 ...