题目描述
输入正数N,输出下列形状的三角形。例如:当N=5时输出: 11 7 12 4 8 13 2 5 9 14 1 3 6 10 15
输入
一个整数N( N <= 10 )
输出
数字三角(每个数字的场宽为4)
样例输入
5
样例输出
11 7 12 4 8 13 2 5 9 14 1 3 6 10 15
提示
来源
//雏形
var a: array[ 1.. 100, 1.. 100] of longint; n,i,j,k:longint; begin readln(n); k:= 1; for i:=n downto 1 do for j:= 1 to n+ 1-i do begin a[i,j]:=k; inc(k); end; for i:= 1 to n do begin for j:= 1 to n do write(a[i,j]: 4); writeln; end; end.
//进化
var a: array[ 1.. 100, 1.. 100] of longint; n,i,j,k:longint; begin readln(n); k:= 1; for i:=n downto 1 do for j:= 1 to n+ 1-i do begin a[i+j- 1,j]:=k; inc(k); end; for i:= 1 to n do begin for j:= 1 to i do write(a[i,j]: 4); writeln; end; end.