A
BBB
CCCCC
DDDDDDD
CCCCC
BBB
A
谢谢了
[此贴子已经被作者于2007-11-1 20:58:43编辑过]
var
i,j,k,l: integer;
s,st: string;
begin
for i := 1 to 4 do
begin
for j := 1 to 4-i do
s := s + ' ';
for j := 1 to 2 * i - 1 do
begin
st:=chr(ord('A')+i-1);
s := s + st;
end;
s := s + chr(13);
end;
for k := 3 downto 1 do
begin
for l := 3-k downto 1 do
s:=s+'';
for j := 2*k-1 downto 1 do
begin
st:=chr(ord('D')-(4-k));
s:=s+st;
end;
s:=s+chr(13);
end;
showmessage(s);
end;
var
i,j,k,l: integer;
s,st: string;
begin
for i := 1 to 4 do
begin
for j := 1 to 4-i do
s := s + ' ';
for j := 1 to 2 * i - 1 do
begin
st:=chr(ord('A')+i-1);
s := s + st;
end;
s := s + chr(13);
end;
for k := 3 downto 1 do
begin
for l := 3-k downto 1 do
s:=s+'';{ 空格没打出来,看了半天才看出来 }
for j := 2*k-1 downto 1 do
begin
st:=chr(ord('D')-(4-k));
s:=s+st;
end;
s:=s+chr(13);
end;
showmessage(s);
end;
我觉得还是有个downto好,不用downto恐怕要用个判断,增加程序的复杂度.
var
i,j,k,l: integer;
s,st: string;
begin
for i := 1 to 4 do
begin
for j := 1 to 4-i do
s := s + ' ';
for j := 1 to 2 * i - 1 do
begin
st:=chr(ord('A')+i-1);
s := s + st;
end;
s := s + chr(13);
end;
for i :=3 downto 1 do
begin
for j := 1 to 4-i do
s := s + ' ';
for j := 1 to 2 * i - 1 do
begin
st:=chr(ord('A')+i-1);
s := s + st;
end;
s := s + chr(13);
end;
showmessage(s);
end;