当前位置:网站首页>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;
}
边栏推荐
- MPLS experiment
- Day-24 UDP, regular expression
- 详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
- Day-18 hash table, generic
- Day-16 set
- 处理链中断后如何继续/子链出错removed from scheduling
- Day-20 file operation, recursive copy, serialization
- [crawler] avoid script detection when using selenium
- How to apply @transactional transaction annotation to perfection?
- [statistical learning method] learning notes - support vector machine (I)
猜你喜欢

opencv的四个函数

Sorting, dichotomy

3D content generation based on nerf

HZOJ #240. 图形打印四

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

Day-19 IO stream

2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)

明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东

Static vxlan configuration

The IDM server response shows that you do not have permission to download the solution tutorial
随机推荐
Day-24 UDP, regular expression
2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
[binary tree] delete points to form a forest
Creation and assignment of graphic objects
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
图像像素读写操作
Four functions of opencv
有什么类方法或是函数可以查看某个项目的Laravel版本的?
谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
【PyTorch实战】图像描述——让神经网络看图讲故事
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
基于NeRF的三维内容生成
Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
What kind of methods or functions can you view the laravel version of a project?
Decrypt gd32 MCU product family, how to choose the development board?
leetcode刷题:二叉树23(二叉搜索树中的众数)