三视图

链接:https://ac.nowcoder.com/acm/contest/85/F
来源:牛客网

题目描述
Etéreo 拿出家里的许多的立方体积木,堆成了一个三维空间中的模型。既然你高考选了技术, 那想必你一定想知道,这个模型的三视图是什么吧!

图中,xx 轴、yy 轴和 zz 轴的方向已经标明。现在规定,图中的红色面为主视面,蓝色面为右视面(注意输出中应为左视而非右视),黄色面为俯视面。具体方向可以观察样例。
输入描述:
第一行四个数 \mathbb{X}, \mathbb{Y}, \mathbb{Z}, \mathbb{N}X,Y,Z,N ,表示该三维空间大小为 \mathbb{X} \times \mathbb{Y} \times \mathbb{Z}X×Y×Z ,且有 \mathbb{N}N 个立方体。
接下去 \mathbb{N}N 行,每行三个整数 x_i, y_i, z_ix
i

,y
i

,z
i

,表示其位置坐标。
输出描述:
输出共 \mathbb{Y} + \mathbb{Z} + 1Y+Z+1 行,前 \mathbb{Y}Y 行每行 \mathbb{X} + \mathbb{Z} + 1X+Z+1 个字符,输出正视图及左视图,两幅图之间有一列空格;接下去输出一个空行;再接下去 \mathbb{Z}Z 行,每行 \mathbb{X}X 个字符,表示俯视图。
其中 \texttt{"."}"." 表示空, \texttt{“x”}“x” 表示有立方体。
示例1
输入
复制
2 2 2 2
1 1 1
2 2 2
输出
复制
.x .x
x. x.

x.
.x
示例2
输入
复制
3 3 3 3
1 1 2
2 1 1
1 2 1
输出
复制
… …
x… x…
xx. xx.

xx.
x…

说明
这里可以把图片拉出去放大看哦~

备注:
1 \leq \mathbb{X}, \mathbb{Y}, \mathbb{Z} \leq 10001≤X,Y,Z≤1000
0 \leq \mathbb{N} \leq 10^50≤N≤10
5

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1010;

char zheng[N][N];
char zuo[N][N];
char fu[N][N];

int main(){
    
    
	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	
	for (int i = 1; i <= N; i ++)
	  for (int j = 1; j <= N; j ++){
    
    
	  	zheng[i][j] = '.';
	  	zuo[i][j] = '.';
	  	fu[i][j] = '.';
	  }
	
	int n;
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i ++){
    
    
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		zheng[b][a] = 'x';
		zuo[c][b] = 'x';
		fu[c][a] = 'x';
	}
	
	for (int i = 1; i <= y; i ++){
    
    
		for (int j = 1; j <= x; j ++)    cout << zheng[y - i + 1][j];
		cout << " ";
		for (int j = 1; j <= z; j ++)   cout << zuo[j][y - i + 1];
		cout << endl;
	}
	
	cout << endl;
	
	for (int i = 1; i <= z; i ++){
    
    
		 for (int j = 1; j <= x; j ++){
    
    
	  	  cout << fu[i][j];
	  }
	  cout << endl;
	}
	 
	
} 

猜你喜欢

转载自blog.csdn.net/qq_45772483/article/details/112603812
今日推荐