当前位置:网站首页>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;
}
边栏推荐
- Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
- Processing strategy of message queue message loss and repeated message sending
- Day-20 file operation, recursive copy, serialization
- JS to convert array to tree data
- Day-15 common APIs and exception mechanisms
- On valuation model (II): PE index II - PE band
- Solve server returns invalid timezone Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
- The left-hand side of an assignment expression may not be an optional property access. ts(2779)
- 2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
- Learning and using vscode
猜你喜欢
H3C HCl MPLS layer 2 dedicated line experiment
Day-18 hash table, generic
[statistical learning methods] learning notes - improvement methods
JS to convert array to tree data
Processing strategy of message queue message loss and repeated message sending
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
BGP third experiment report
leetcode刷题:二叉树19(合并二叉树)
【PyTorch实战】用RNN写诗
Customize the web service configuration file
随机推荐
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
[statistical learning methods] learning notes - improvement methods
About web content security policy directive some test cases specified through meta elements
Day-15 common APIs and exception mechanisms
什么是ESP/MSR 分区,如何建立ESP/MSR 分区
JS to convert array to tree data
密码学系列之:在线证书状态协议OCSP详解
Cryptography series: detailed explanation of online certificate status protocol OCSP
【二叉树】删点成林
Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
【PyTorch实战】用RNN写诗
Niuke website
Tutorial on the principle and application of database system (011) -- relational database
Realize a simple version of array by yourself from
【从 0 开始学微服务】【00】课程概述
Experiment with a web server that configures its own content
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
Sort out the garbage collection of JVM, and don't involve high-quality things such as performance tuning for the time being
[爬虫]使用selenium时,躲避脚本检测
ip2long与long2IP 分析