program molecule; var a: array[0..30, 0..30, 0..30] of boolean; x, y, z, i: integer; t: boolean; f: text; procedure writeheader; begin writeln(f, 'object {'); writeln(f, ' union {'); end; procedure writefooter; begin writeln(f, ' }'); writeln(f, ' pigment { color green 1}'); writeln(f, ' translate <-15, -15, -15>'); writeln(f, ' scale <0.2, 0.2, 0.2>'); writeln(f, '}'); end; procedure writepiece (a, b, c: real); begin writeln(f, ' sphere { <', a, ', ', b, ', ', c, '> .2 }'); write('.'); {progress on text window} end; function vertices (x, y, z: integer): boolean; begin if a[x, y, z] = true then vertices := false else if a[x + 1, y + 1, z + 1] or a[x + 1, y + 1, z - 1] or a[x + 1, y - 1, z + 1] or a[x + 1, y - 1, z - 1] or a[x - 1, y + 1, z + 1] or a[x - 1, y + 1, z - 1] or a[x - 1, y - 1, z + 1] or a[x - 1, y - 1, z - 1] then vertices := true else vertices := false; end; procedure molecule; var x, y, z, i: integer; begin for x := 0 to 30 do for y := 0 to 30 do for z := 0 to 30 do a[x, y, z] := false; a[15, 15, 15] := true; writepiece(15, 15, 15); i := 0; repeat i := i + 1; repeat x := abs(random mod 29) + 1; y := abs(random mod 29) + 1; z := abs(random mod 29) + 1; until vertices(x, y, z); a[x, y, z] := true; writepiece(x, y, z); until i > 300; end; begin showtext; rewrite(f, 'molecule.inc'); writeheader; molecule; writefooter; close(f); end.