pascal语言蛇形矩阵程序 如下 :program ex9;vara:array[1..10,1..10]of integer;d,n,i,j,m,x:integer;beginreadln(n);i:=1;j:=1;d:=1;m:=1;repeat a[i,j]:=m;case d of1:begin i:=i+1;if j=1 then d:=2else d:=4;end;2:begin i:=i-1;j:=j+1;if j=N then d:=
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/11 20:36:14
![pascal语言蛇形矩阵程序 如下 :program ex9;vara:array[1..10,1..10]of integer;d,n,i,j,m,x:integer;beginreadln(n);i:=1;j:=1;d:=1;m:=1;repeat a[i,j]:=m;case d of1:begin i:=i+1;if j=1 then d:=2else d:=4;end;2:begin i:=i-1;j:=j+1;if j=N then d:=](/uploads/image/z/5388370-34-0.jpg?t=pascal%E8%AF%AD%E8%A8%80%E8%9B%87%E5%BD%A2%E7%9F%A9%E9%98%B5%E7%A8%8B%E5%BA%8F+%E5%A6%82%E4%B8%8B+%EF%BC%9Aprogram+ex9%3Bvara%3Aarray%5B1..10%2C1..10%5Dof+integer%3Bd%2Cn%2Ci%2Cj%2Cm%2Cx%3Ainteger%3Bbeginreadln%28n%29%3Bi%3A%3D1%3Bj%3A%3D1%3Bd%3A%3D1%3Bm%3A%3D1%3Brepeat+a%5Bi%2Cj%5D%3A%3Dm%3Bcase+d+of1%3Abegin+i%3A%3Di%2B1%3Bif+j%3D1+then+d%3A%3D2else+d%3A%3D4%3Bend%3B2%3Abegin+i%3A%3Di-1%3Bj%3A%3Dj%2B1%3Bif+j%3DN+then+d%3A%3D)
pascal语言蛇形矩阵程序 如下 :program ex9;vara:array[1..10,1..10]of integer;d,n,i,j,m,x:integer;beginreadln(n);i:=1;j:=1;d:=1;m:=1;repeat a[i,j]:=m;case d of1:begin i:=i+1;if j=1 then d:=2else d:=4;end;2:begin i:=i-1;j:=j+1;if j=N then d:=
pascal语言蛇形矩阵程序 如下 :
program ex9;
var
a:array[1..10,1..10]of integer;
d,n,i,j,m,x:integer;
begin
readln(n);
i:=1;j:=1;d:=1;m:=1;
repeat a[i,j]:=m;
case d of
1:begin i:=i+1;
if j=1 then d:=2
else d:=4;
end;
2:begin i:=i-1;j:=j+1;
if j=N then d:=1
else if i=1 then d:=3;
end;
3:begin j:=j+1;
if i=N then d:=2
else d:=4;
end;
4:begin i:=i+1;j:=j-1;
if i=N then d:=3
else if j=1 then d:=1;
end;
end;
m:=m+1;
until m>n*n;
for i:=1 to n do
begin
for j:=1 to n do write(a[i,j]:4);
writeln;
end;
readln;
end.
pascal语言蛇形矩阵程序 如下 :program ex9;vara:array[1..10,1..10]of integer;d,n,i,j,m,x:integer;beginreadln(n);i:=1;j:=1;d:=1;m:=1;repeat a[i,j]:=m;case d of1:begin i:=i+1;if j=1 then d:=2else d:=4;end;2:begin i:=i-1;j:=j+1;if j=N then d:=
program ex9;
var
a:array[1..10,1..10]of integer;【矩阵10*10】
d【判别符号】,n【矩阵大小】,i【横坐标】,j【纵坐标】,m【次数,赋值大小】,x【不好意思,我没看见】:integer;
begin
readln(n);
i:=1;j:=1;d:=1;m:=1;
repeat a[i,j]:=m【赋值a[i,j]】;
case d of
1:begin i:=i+1;【向右移动1个单位】
if j=1 then d:=2
else d:=4;
end;
2:begin i:=i-1;j:=j+1;【向左下移动】
if j=N then d:=1
else if i=1 then d:=3;
end;
3:begin j:=j+1;【向下移动一个个单位】
if i=N then d:=2
else d:=4;
end;
4:begin i:=i+1;j:=j-1;【向右上移动】
if i=N then d:=3
else if j=1 then d:=1;
end;
end;
m:=m+1;
until m>n*n;
for i:=1 to n do【输出n行】
begin
for j:=1 to n do write(a[i,j]:4);【输出a[i,j],占4个单位】
writeln;【换行】
end;
readln;【等待用户反应】
end.