主题:书上的程序,我想不通,也看不懂,调试也不对。请求解答
cskeleton
[专家分:10] 发布于 2005-07-24 14:59:00
试编写能够打印输出如下图形的程序:
###########
#########
#######
#####
###
#
Program p4_32;
var
i,j,k:integer;
begin
for i:=6 downto 1 do
begin
for j:=1 to 6-i do
write(' ' , 30-i);
for k:=2*i-1 downto 1 do
writeln('#');
end;
readln;
end.
回复列表 (共5个回复)
沙发
cskeleton [专家分:10] 发布于 2005-07-24 15:23:00
我自己改了一下程序,就可以了:
Program p4_32;
var
i,j,k:integer;
begin
for i:=6 downto 1 do
begin
for j:=1 to 6-i do
write(' ' );
for k:=2*i-1 downto 1 do
begin
write('#');
end;
writeln;
end;
readln;
end.
板凳
davidw017 [专家分:4170] 发布于 2005-07-24 17:41:00
你这是什么意思呢?
3 楼
brianzf [专家分:30] 发布于 2005-07-28 14:08:00
我也写拉一个,hangshu:=(geshu+1) div 2要注意
program usewrite;
var a,b,c,konggeshu,geshu,hangshu:integer;
begin
write('input the num of the first line:');
readln(geshu);
if geshu>0
then
begin
hangshu:=(geshu+1) div 2;
konggeshu:=0;
for a:=1 to hangshu do
begin
for b:=1 to konggeshu do
begin
write(' ');
end;
konggeshu:=konggeshu+1;
for c:=1 to geshu do
begin
write('#');
end;
geshu:=geshu-2;
writeln('')
end;
end
else
writeln('creat error!');
end.
4 楼
brianzf [专家分:30] 发布于 2005-07-28 14:10:00
我觉的书上的算法好紧凑哦,好难想的!
我来回复