补全输出下列图形所缺的程序,即( )内的程序,图形的行数和列数为n,n是奇数,1大于等于n,小于等于20。
0 1 1 1 0
1 0 1 0 1
1 1 0 1 1
1 0 1 0 1
0 1 1 1 0
const maxn=20;
type arr=array[1maxn,1maxn] of integer;
var a:arr; n,i,j:integer;
begin
readln(n);
for i:=1 to n do
for j:=1 to n do a[i,j]:=1;
for i:=1 to n do
begin ( ); ( ); end;
for i:=1 to n do
begin
for j:=1 to n do write(a[i,j]:3]);
writeln;
end;
end
program exp4;
Var i,j,n,k : integer;
a :array [1100] of integer;
b,d:array [0100] of integer;
s :array[130] of integer;
begin
readln(n,k);
for I:=1 to n do read(a[I]);
for I:=0 to n do b[I]:=1;
cmin:=1000000;
while (b[0]=1) do
begin
for I:=1 to k do s[i]:=1;
for I:=1 to n do
s[b[i]]:=s[b[i]]+a[i];
sum:=0;
for I:=1 to k-1 do
for j:=i+1 to k do
sum:=sum+(s[I]-s[j])(s[I]-s[j]);
if sum<cmin then
begin
cmin:=sum;
for I:=1 to n do d[I]:=b[I];
end;
j:=n;
while b[j]=k do j:=j-1;
b[j]:=b[j]+1;
for I:=j+1 to n do b[i]:=1;
end;
writeln(cmin);
for I:=1 to n do write(d[I]:40);
writeln;
end
以上就是关于pascal编程:完善程序全部的内容,包括:pascal编程:完善程序、pascal 完善程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)