当前位置:网站首页>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;
}
边栏推荐
- [statistical learning method] learning notes - support vector machine (I)
- SQL Lab (41~45) (continuous update later)
- What is an esp/msr partition and how to create an esp/msr partition
- Preorder, inorder and postorder traversal of binary tree
- 图像像素读写操作
- NPM instal reports agent or network problems
- Static routing assignment of network reachable and telent connections
- Attack and defense world ----- summary of web knowledge points
- Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
- "Series after reading" my God! It's so simple to understand throttling and anti shake~
猜你喜欢

ps链接图层的使用方法和快捷键,ps图层链接怎么做的

SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels

Processing strategy of message queue message loss and repeated message sending

Master公式。(用于计算递归的时间复杂度。)

Day-19 IO stream
![[statistical learning method] learning notes - logistic regression and maximum entropy model](/img/f7/857d053cc2cee81c24919aafab3c6e.png)
[statistical learning method] learning notes - logistic regression and maximum entropy model

【PyTorch实战】用RNN写诗

SQL head injection -- injection principle and essence

Day-15 common APIs and exception mechanisms

leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
随机推荐
ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
leetcode刷题:二叉树19(合并二叉树)
How to use PS link layer and shortcut keys, and how to do PS layer link
(to be deleted later) yyds, paid academic resources, please keep a low profile!
When OSPF specifies that the connection type is P2P, it enables devices on both ends that are not in the same subnet to Ping each other
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
Vxlan static centralized gateway
[statistical learning method] learning notes - support vector machine (I)
【统计学习方法】学习笔记——第五章:决策树
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
JS to convert array to tree data
Day-17 connection set
Tutorial on principles and applications of database system (009) -- conceptual model and data model
30. Feed shot named entity recognition with self describing networks reading notes
Using stack to convert binary to decimal
Day-18 hash table, generic
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
【统计学习方法】学习笔记——支持向量机(下)
[statistical learning method] learning notes - support vector machine (Part 2)
Tutorial on the principle and application of database system (011) -- relational database