Home > Back-end > Happy New Year to the brothers and sisters. By the way, ask a question.
Happy New Year to the brothers and sisters. By the way, ask a question.
Time:09-25
Suppose there is a big cube is similar to a rubik's cube by n * n * n small stack, use graph structure to store, each small pieces for a node, a value of 0 or 1, now wants to non-zero cube surface nodes to dig out, make the human eye can see small values are 1, pay attention to every block, dig out the human eye would see the new surface, non-zero node in the new surface continue to dig out, until the human eye can see small values are 1, the case may be, when to dig down along a certain direction are all zero, the cube to dig a hole,
Please everybody, glad to give some thought to also go,
Thank you,
CodePudding user response:
A, define the type of three dimensional array Type TArr=array [0.. 19, 0.. 19, 0), 19] of Byte;//data model 20 * 20 * 20 TArr1=array [0.. 19, 0.. 19] of Byte;//merge longitudinal model fully
Second, define global array variable Var M: TArr;//data model M1: TArr;//merge longitudinal appear a
Three, the initialization Description: three dimensional array X (horizontal) Y (solid) Z (vertical), cyclic variable I, j, k, Procedure TForm1. Button1Click (Sender: TObject); Var I, j, k: integer; The begin Randomize. For k:=0 to 19 do For j:=0 to 19 do For I:=0 to 19 do M [I, j, k] :=the random (2);//a random number 0 and 1 end;
Four, search combined longitudinal fully Var T: Boolean; I, j, k, kk: integer; The begin Kk:=5;//merge 1-6 layer For I:=0 to 19 do For I:=0 to 19 do The begin T:=True; For k:=0 to kk do If [k, I, j]=1: then T=False; If T then [I, j] : M1=0 Else M1: [I, j]=1; end; end;
Five, the graphics Through the Memo character graphics, if draw pictures, write their own,