Delphi 打印杨辉三角


program
yanghui1; {$APPTYPE CONSOLE} uses SysUtils; var i,j,t,n:Integer; a:array[0..14,0..14] of Integer; begin write(请输入行数:); readln(n); for i:=0 to n-1 do begin a[i][0]:=1; //初始化第一列 end; for i:=1 to n-1 do begin for j:=1 to i do begin a[i][j]:=a[i-1][j-1]+a[i-1][j]; end; end; // Writeln(a[15][7]); for i:=0 to n-1 do begin
for t:=0 to n-i do begin write(‘‘:2); //控制空格 end;
for j:=0 to i do begin write(a[i][j]:4); //输出对应的数 end;
Writeln;
end; Readln; end.

 

 

Delphi  打印杨辉三角

Delphi 打印杨辉三角

上一篇:alpha-beta filter


下一篇:HTML5+Ajax+Jquery调用Google搜索API实现搜索引擎,支持web,image,news,vedio4种模式!