• HDU 6330--Visual Cube(构造,计算)


    Visual Cube

    • 将这个立方体分块,分成上中下三个部分,利用长宽高计算行列,最后输出即可。
      每个部分都分成奇偶行来输出,总共有(2*(b+c)+1)行,共(2*(a+b)+1)列。设当前行为(i),划分方式:当行数小于等于(2*b)时,在上部,当$i > (2 * b) $ && (i<=2*c+1)时,在中部,其余在下部。这样的划分可以应对绝大部分情况,但是对于上部有一中情况是不包括的,当$b>c $时,如果继续之前的划分,那么在头部判定之后,它依然符合下部的判定,所以这时也被当作下部输出,这不是预期的结果,所以在上部加上额外的判定。
    
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #include<cstdio>
    using namespace std;
    int main(void) {
    	int t, a, b, c;
    	cin >> t;
    	while (t-- > 0) {
    		cin >> a >> b >> c;
    		for (int i = 1; i <= (2 * (b + c) + 1); i++) {
    			//if (i != 1)cout << endl;
    			//head
    			if (i % 2 == 1 && i <= (2 * b)) {
    				for (int j = 1; j <= 2*(b-i/2); j++) {
    					cout << ".";
    				}
    				for (int j = 2 * (b - i / 2) + 1; j <= 2 * (b - i / 2) + a * 2; j+=2) {
    					cout << "+-";
    				}
    				cout << "+";
    				if (b < c || i <= (2 * c + 1)) {
    					for (int j = 2 * (b - i / 2) + a * 2 + 2; j <= 2 * (a + b) + 1; j += 2) {
    						cout << ".+";
    					}
    				}
    				else
    				{
    					cout << ".";
    					for (int j = 1; j <= c; j++) {
    						cout << "+.";
    					}
    					for (int j = 2 * (b - i / 2) + a * 2 + 2*c+3; j <= 2 * (a + b) + 1; j++) {
    						cout << ".";
    					}
    				}
    				cout << endl;
    				continue;
    			}
    			if (i % 2 == 0 && i <= (2 * b)) {
    				for (int j = 1; j <= 2 * (b - i / 2)+1; j++) {
    					cout << ".";
    				}
    				for (int j = 2 * (b - i / 2) + 1; j <= 2 * (b - i / 2) + a * 2; j += 2) {
    					cout << "/.";
    				}
    				if (b < c ||i<=(2*c+1)) {
    					for (int j = 2 * (b - i / 2) + a * 2 + 2; j <= 2 * (a + b) + 1; j += 2) {
    						cout << "/|";
    					}
    				}
    				else
    				{
    					cout << "/";
    					for(int j=1;j<=c;j++){
    						cout << "|/";
    					}
    					for (int j = 2 * (b - i / 2) + a * 2+2*c+3; j <= 2 * (a + b) + 1; j++) {
    						cout << ".";
    					}
    				}
    				cout << endl;
    				continue;
    			}
    			//middle
    			if (i % 2 == 1 && i > (2 * b)&& i<=2*c+1) {
    				for (int j = 1; j <= 2 * a; j+=2) {
    					cout << "+-";
    				}
    				cout << "+";
    				for (int j = 2 * (a+1); j <= 2 * (a + b) + 1; j += 2) {
    					cout << ".+";
    				}
    				cout << endl;
    				continue;
    			}
    			if (i % 2 == 0 && i > (2 * b) && i <= 2 * c + 1) {
    				for (int j = 1; j <= 2 * a; j+=2) {
    					cout << "|.";
    				}
    				cout << "|";
    				for (int j = 2 * (a + 1); j <= 2 * (a + b) + 1; j += 2) {
    					cout << "/|";
    				}
    				cout << endl;
    				continue;
    			}
    			//bottom
    			if (i % 2 == 1 && i > (2 * c + 1)) {
    				for (int j = 1; j <= 2 * a; j+=2) {
    					cout << "+-";
    				}
    				cout << "+";
    				int k = (2 * (c + b) + 1 - i) / 2+1;
    				for (int j = 1; j <= k-1; j++) {
    					cout << ".+";
    				}
    				for (int j = 2 * a + 1 + 2 * k; j <= 2 * (a + b) + 2; j++) {
    					cout << ".";
    				}
    				cout << endl;
    				continue;
    			}
    			if (i % 2 == 0 && i > (2 * c + 1)) {
    				for (int j = 1; j <= 2 * a; j+=2) {
    					cout << "|.";
    				}
    				int k = (2 * (c + b) + 1 - i) / 2+1;
    				for (int j = 1; j <= k; j++) {
    					cout << "|/";
    				}
    				for (int j = 2 * a + 1 + 2 * k; j <= 2 * (a + b) + 1; j++) {
    					cout << ".";
    				}
    				cout << endl;
    				continue;
    			}
    		}
    	}
    	return 0;
    }
    
  • 相关阅读:
    mysql 语法
    mycat 配置简介
    redis sentinel 配置
    Spark SQL 读到的记录数与 hive 读到的不一致
    HDP3.1 中 YRAN 和 MR2 的内存大小配置的计算方式
    在 windows 下搭建 IDEA + Spark 连接 Hive 的环境
    HDP3.1 中配置 YARN 的 timeline server 使用外部的 HBase
    大规模使用 Apache Kafka 的20个最佳实践
    卸载mac版本的GlobalProtect
    js解决约瑟夫问题
  • 原文地址:https://www.cnblogs.com/FlyerBird/p/9403338.html
Copyright © 2020-2023  润新知