当前位置:网站首页>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;
}
边栏推荐
- Niuke website
- Common knowledge of one-dimensional array and two-dimensional array
- SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels
- leetcode刷题:二叉树19(合并二叉树)
- Realize a simple version of array by yourself from
- ip2long之后有什么好处?
- ip2long与long2IP 分析
- In the small skin panel, use CMD to enter the MySQL command, including the MySQL error unknown variable 'secure_ file_ Priv 'solution (super detailed)
- NGUI-UILabel
- 基于NeRF的三维内容生成
猜你喜欢

【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型

The road to success in R & D efficiency of 1000 person Internet companies

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

visual stdio 2017关于opencv4.1的环境配置

ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型

leetcode刷题:二叉树19(合并二叉树)

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

Preorder, inorder and postorder traversal of binary tree

2022聚合工艺考试题模拟考试题库及在线模拟考试

【统计学习方法】学习笔记——提升方法
随机推荐
Epp+dis learning path (1) -- Hello world!
Realize all, race, allsettled and any of the simple version of promise by yourself
SQL injection -- Audit of PHP source code (take SQL lab 1~15 as an example) (super detailed)
visual stdio 2017关于opencv4.1的环境配置
Day-15 common APIs and exception mechanisms
Configure an encrypted web server
SQL blind injection (WEB penetration)
SQL lab 11~20 summary (subsequent continuous update) contains the solution that Firefox can't catch local packages after 18 levels
gcc 编译报错
Cookie
[learn micro services from 0] [02] move from single application to service
leetcode刷题:二叉树23(二叉搜索树中的众数)
2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
The left-hand side of an assignment expression may not be an optional property access.ts(2779)
[pytorch practice] image description -- let neural network read pictures and tell stories
mysql怎么创建,删除,查看索引?
Processing strategy of message queue message loss and repeated message sending
Static vxlan configuration
How to use PS link layer and shortcut keys, and how to do PS layer link
Sort out the garbage collection of JVM, and don't involve high-quality things such as performance tuning for the time being