当前位置:网站首页>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;
}
边栏推荐
- Error in compiling libssl
- mysql怎么创建,删除,查看索引?
- SQL Lab (32~35) contains the principle understanding and precautions of wide byte injection (continuously updated later)
- Epp+dis learning path (1) -- Hello world!
- About sqli lab less-15 using or instead of and parsing
- 图像像素读写操作
- H3C HCl MPLS layer 2 dedicated line experiment
- BGP third experiment report
- 什么是ESP/MSR 分区,如何建立ESP/MSR 分区
- 【统计学习方法】学习笔记——支持向量机(上)
猜你喜欢

Minimalist movie website

leetcode刷题:二叉树26(二叉搜索树中的插入操作)

Day-16 set

Several ways to clear floating

Common knowledge of one-dimensional array and two-dimensional array

Decrypt gd32 MCU product family, how to choose the development board?

leetcode刷题:二叉树22(二叉搜索树的最小绝对差)

Attack and defense world - PWN learning notes

Tutorial on principles and applications of database system (010) -- exercises of conceptual model and data model

About sqli lab less-15 using or instead of and parsing
随机推荐
Dialogue with Wang Wenyu, co-founder of ppio: integrate edge computing resources and explore more audio and video service scenarios
Session
Day-19 IO stream
[pytorch practice] write poetry with RNN
Polymorphism, final, etc
What if does not match your user account appears when submitting the code?
【深度学习】图像多标签分类任务,百度PaddleClas
Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
Cookie
图形对象的创建与赋值
【从 0 开始学微服务】【01】什么是微服务
OSPF exercise Report
Visual stdio 2017 about the environment configuration of opencv4.1
Day-15 common APIs and exception mechanisms
Vxlan 静态集中网关
金融数据获取(三)当爬虫遇上要鼠标滚轮滚动才会刷新数据的网页(保姆级教程)
通讯协议设计与实现
The road to success in R & D efficiency of 1000 person Internet companies
How to use PS link layer and shortcut keys, and how to do PS layer link
静态Vxlan 配置