【HDOJ6330】Visual Cube(模拟)

题意:

思路:

  1 import java.util.Scanner;
  2 
  3 public class Main {
  4     public static void main(String args[]) {
  5         Scanner la = new Scanner(System.in);
  6         int S = la.nextInt();
  7         while(S != 0) {
  8             --S;
  9         int a = la.nextInt(), b = la.nextInt(), c = la.nextInt();
 10         int A = 2 * a + 1, B = 2 * b + 1, C = 2 * c + 1;
 11         int x = A + B - 1;
 12         int y = C + B - 1;
 13         String JK[][] = new String[1000][1000];
 14         
 15         
 16             
 17         String out = "+";
 18         String nextout = "-";
 19         String line = "|";
 20         String linenext = ".";
 21         Boolean flagout = true;
 22         Boolean flagline = true;
 23         for (int n = B - 1; n < y; n++) {
 24             flagout = true;
 25             if (flagline) {
 26                 for (int m = 0; m < A; m++) {
 27 
 28                     if (flagout) {
 29                         JK[n][m] = out;
 30                         flagout = false;
 31                     } else {
 32                         flagout = true;
 33                         JK[n][m] = nextout;
 34                     }
 35                 }
 36                 flagline = false;
 37             } else {
 38                 for (int m = 0; m < A; m++) {
 39 
 40                     if (flagout) {
 41                         JK[n][m] = line;
 42                         flagout = false;
 43                     } else {
 44                         flagout = true;
 45                         JK[n][m] = linenext;
 46                     }
 47                 }
 48                 flagline = true;
 49             }
 50         }
 51         // 上面
 52         int num = B - 1;
 53         out = "+";
 54         nextout = "-";
 55         line = "/";
 56         linenext = ".";
 57         flagout = true;
 58         flagline = true;
 59         for(int i=B-2;i>=0;i--) {
 60             for(int w=B-2;w>=0;w--) {        
 61                 JK[i][w]=".";
 62                 JK[y-(i+1)][x-(w+1)]=".";
 63             }
 64         }
 65             for (int n = 0; n < B-1; n++) {
 66                 int i=B-1-n-1;
 67                 flagout = true;
 68                 if (flagline) {
 69                     for (int m = 0; m < A; m++) {
 70                         if (flagout) {
 71                             //System.out.println("m="+m+",i="+i);
 72                             JK[n][m+i+1] = out;
 73                             flagout = false;
 74                         } else {
 75                             flagout = true;
 76                             //System.out.println("m="+m+",i="+i);
 77                             JK[n][m+i+1] = nextout;
 78                         }
 79                     }
 80                     flagline = false;
 81                 } else {
 82                     for (int m = 0; m < A; m++) {
 83 
 84                         if (flagout) {
 85                             JK[n][m+i+1] = line;
 86                             flagout = false;
 87                         } else {
 88                             flagout = true;
 89                             JK[n][m+i+1] = linenext;
 90                         }
 91                     }
 92                     flagline = true;
 93                 }
 94             }
 95             // 右面
 96             num = B - 1;
 97             out = "+";
 98             nextout = "|";
 99             line = "/";
100             linenext = ".";
101             flagout = true;
102             flagline = true;
103             
104                 for (int n = 0; n < B-1; n++) {
105                     //System.out.println(",n="+n);
106                     flagout = true;
107                     if (flagline) {
108                         for (int m =0; m < y-B+1; m++) {
109                             if (flagout) {
110                                 //System.out.println("m="+m+",n="+n);
111                                 JK[m+n][x-1-n] = out;
112                                 flagout = false;
113                             } else {
114                                 flagout = true;
115                                 //System.out.println("m="+m+",n="+n);
116                                 JK[m+n][x-1-n] = nextout;
117                             }
118                         }
119                         flagline = false;
120                     } else {
121                         for (int m = 0; m < y-B+1; m++) {
122 
123                             if (flagout) {
124                                 //System.out.println("m="+m+",n="+n);
125                                 JK[m+n][x-1-n] = line;
126                                 flagout = false;
127                             } else {
128                                 flagout = true;
129                                 //System.out.println("m="+m+",n="+n);
130                                 JK[m+n][x-1-n] = linenext;
131                             }
132                         }
133                         flagline = true;
134                     }
135                 }
136         
137 
138         
139             for(int m=0;m<y;m++) {
140                 for(int n=0;n<x;n++) {
141                     System.out.print(JK[m][n]);
142                 }System.out.println();
143             }
144             
145     }
146 }}

 

posted on 2018-08-02 10:52  myx12345  阅读(204)  评论(0编辑  收藏  举报

导航