当前位置:网站首页>HZOJ #240. 图形打印四
HZOJ #240. 图形打印四
2022-07-07 10:36:00 【段舸】
题目:240. 图形打印四
题目传送门:240题
样例输入
1
2
3
4
-1
样例输出
X
-
X X
X
X X
-
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
-
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
-
数据规模与约定
时间限制:1 s
内存限制:256 M
100% 的数据保证 1≤n≤7
代码
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
char ans[1005][1005];
int num[10] = { 0,1,3,9,27,81,243,729 };
void func(int x, int y, int n)
{
if (n == 1) {
ans[x][y] = 'X';
return;
}
func(x, y, n - 1);
func(x, y + num[n] / 3 * 2, n - 1);
func(x + num[n] / 3 * 2, y, n - 1);
func(x + num[n] / 3, y + num[n] / 3, n - 1);
func(x + num[n] / 3 * 2, y + num[n] / 3 * 2, n - 1);
}
int main()
{
func(1, 1, 7);
int n;
while (cin >> n)
{
if (n == -1) {
break;
}
for (int i = 1; i <= num[n]; i++)
{
for (int j = 1; j <= num[n]; j++)
{
if (ans[i][j] == 'X') {
cout << 'X';
}
else {
cout << ' ';
}
}
cout << endl;
}
cout << '-' << endl;
}
return 0;
}
边栏推荐
- 解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
- 图形对象的创建与赋值
- [爬虫]使用selenium时,躲避脚本检测
- 通讯协议设计与实现
- 广州市召开安全生产工作会议
- SQL Lab (46~53) (continuous update later) order by injection
- 【统计学习方法】学习笔记——支持向量机(下)
- About web content security policy directive some test cases specified through meta elements
- BGP actual network configuration
- Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
猜你喜欢
聊聊Redis缓存4种集群方案、及优缺点对比
SQL lab 26~31 summary (subsequent continuous update) (including parameter pollution explanation)
Decrypt gd32 MCU product family, how to choose the development board?
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
leetcode刷题:二叉树21(验证二叉搜索树)
Visual stdio 2017 about the environment configuration of opencv4.1
Inverted index of ES underlying principle
Attack and defense world - PWN learning notes
Minimalist movie website
Idea 2021 Chinese garbled code
随机推荐
SQL lab 21~25 summary (subsequent continuous update) (including secondary injection explanation)
2022-07-07日报:GAN发明者Ian Goodfellow正式加入DeepMind
leetcode刷题:二叉树24(二叉树的最近公共祖先)
Simple implementation of call, bind and apply
Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
About sqli lab less-15 using or instead of and parsing
H3C HCl MPLS layer 2 dedicated line experiment
ps链接图层的使用方法和快捷键,ps图层链接怎么做的
Preorder, inorder and postorder traversal of binary tree
Several methods of checking JS to judge empty objects
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
用mysql查询某字段是否有索引
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
Tutorial on principles and applications of database system (009) -- conceptual model and data model
ip2long之后有什么好处?
【PyTorch实战】用RNN写诗
Several ways to clear floating
How much does it cost to develop a small program mall?
Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed