Loading...

    AD: 猛买 | 快递查询 | Jobsdigg | 很棒的男装店

用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写一个数字金字塔”


  1. No Comments

Leave a Reply