当前位置:网站首页>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;
}
边栏推荐
- NGUI-UILabel
- SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
- leetcode刷题:二叉树26(二叉搜索树中的插入操作)
- Tutorial on the principle and application of database system (008) -- exercises on database related concepts
- gcc 编译报错
- Using stack to convert binary to decimal
- Experiment with a web server that configures its own content
- When OSPF specifies that the connection type is P2P, it enables devices on both ends that are not in the same subnet to Ping each other
- Is it safe to open an account in Ping An Securities mobile bank?
- Utiliser la pile pour convertir le binaire en décimal
猜你喜欢

leetcode刷题:二叉树20(二叉搜索树中的搜索)

【统计学习方法】学习笔记——第五章:决策树

The left-hand side of an assignment expression may not be an optional property access. ts(2779)

JS to convert array to tree data

Airserver automatically receives multi screen projection or cross device projection

Minimalist movie website

数据库安全的重要性

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

Epp+dis learning road (2) -- blink! twinkle!

SQL Lab (41~45) (continuous update later)
随机推荐
[statistical learning method] learning notes - support vector machine (I)
Day-16 set
Day-14 common APIs
PHP调用纯真IP数据库返回具体地址
About web content security policy directive some test cases specified through meta elements
GCC compilation error
RHSA first day operation
2022广东省安全员A证第三批(主要负责人)考试练习题及模拟考试
【从 0 开始学微服务】【02】从单体应用走向服务化
如何将 @Transactional 事务注解运用到炉火纯青?
SQL blind injection (WEB penetration)
ip2long之后有什么好处?
Solutions to cross domain problems
Niuke website
Minimalist movie website
Customize the web service configuration file
图形对象的创建与赋值
SQL Lab (32~35) contains the principle understanding and precautions of wide byte injection (continuously updated later)
Tutorial on the principle and application of database system (008) -- exercises on database related concepts
数据库安全的重要性