当前位置:网站首页>HZOJ #240. Graphic printing IV
HZOJ #240. Graphic printing IV
2022-07-07 12:50:00 【Duange】
subject :240. Graphic printing IV
Subject portal :240 topic
The sample input
1
2
3
4
-1
Sample output
X
-
X X
X
X X
-
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
-
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
-
Data scale and agreement
The time limit :1 s
Memory limit :256 M
100% Data assurance for 1≤n≤7
Code
#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;
}
边栏推荐
- IPv6 experiment
- [binary tree] delete points to form a forest
- ip2long之后有什么好处?
- 【从 0 开始学微服务】【01】什么是微服务
- OSPF exercise Report
- 明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
- 处理链中断后如何继续/子链出错removed from scheduling
- 2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
- Preorder, inorder and postorder traversal of binary tree
- What if does not match your user account appears when submitting the code?
猜你喜欢
Importance of database security
Zhimei creative website exercise
Cookie
Multi row and multi column flex layout
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
[爬虫]使用selenium时,躲避脚本检测
Creation and assignment of graphic objects
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
Leetcode brush questions: binary tree 19 (merge binary tree)
BGP third experiment report
随机推荐
基于NeRF的三维内容生成
Routing strategy of multi-point republication [Huawei]
The left-hand side of an assignment expression may not be an optional property access. ts(2779)
怎样重置火狐浏览器
On valuation model (II): PE index II - PE band
What kind of methods or functions can you view the laravel version of a project?
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
Cookie
Static routing assignment of network reachable and telent connections
Day-19 IO stream
利用栈来实现二进制转化为十进制
【从 0 开始学微服务】【00】课程概述
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
Layer pop-up layer closing problem
ICLR 2022 | pre training language model based on anti self attention mechanism
[爬虫]使用selenium时,躲避脚本检测
[learn microservices from 0] [03] explore the microservice architecture
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
如何将 @Transactional 事务注解运用到炉火纯青?
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东