懂pascal的进

来源:百度知道 编辑:UC知道 时间:2024/07/07 12:15:35
1.输出斐波列契数列的前N项(5个1行)
0 1 1 2 3 5 8 13 21 . . . . . . . . . .
2.输入N个整数,找出最大数所在位置,并将它与第一个数对调位置。
3.读入n个数,打印其中的最大数及其位置号
用一维数组帮帮忙

1.program shu;
var a:array[1..100] of integer;
i:integer;
const n=11;
begin
assign(output,'shu.out');
rewrite(output);
a[1]:=0;
a[2]:=1;
for i:=3 to n do a[i]:=a[i-1]+a[i-2];
for i:=1 to n do begin
write(a[i],' ');
if i mod 5=0 then writeln;
end;
close(output);
end.
2.
program daxiao;
const n=11;
var max,i,j:integer;
a:array[1..100] of integer;
begin
assign(input,'daxiao.in');
assign(output,'daxiao.out');
reset(input);
rewrite(output);
for i:=1 to n do read(a[i]);
max:=1;
for i:=2 to n do if a[i]>a[max] then max:=i;
j:=a[1];
a[1]:=a[max];
a[max]:=j;
writeln(max);
for i:=1 to n do write(a[i],' ');
close(input);
close(output);
end.
3.
program zuida;
const n=11;
var max,i,j:integer;
a:array[1..100] of inte