用delphi写一个数字金字塔
原文地址:http://www.blogkid.net/archives/67.html
Code:
program Project2;{$APPTYPE CONSOLE}
uses
SysUtils;
var
a,b,c,d : Integer ; //declare variables
begin
write(‘请输入一个自然数’) ;
readln(a);
for b:=1 to a do //start from the first row
begin
for c:=1 to a-b do //write blanks before numbers
write(#32) ;
for d:=1 to b do //write numbers
write(d);
for d:=b-1 downto 1 do
write(d);
for c:=1 to a-b do //write blanks after numbers
write(#32); //turn to the next row
write(#10#13) ;
end ;
{ TODO -oUser -cConsole Main : Insert code here }
writeln(‘输入回车结束’);
readln;
end.


0 Responses to “用delphi写一个数字金字塔”