0 bình luận về “Số hạng lớn nhất của dãy và chỉ số của nó.”
program hama; uses crt; var A: array[1..500] of integer; i, n, max, d: integer; begin clrscr; write(‘Nhap n = ‘); readln(n); for i:=1 to n do begin write(‘A[‘, i, ‘] = ‘); readln(A[i]); end; max:=A[1]; for i:=1 to n do if max<A[i] then begin max:=A[i]; d:=i; end; writeln(‘So hang lon nhat: ‘, max); write(‘Chi so cua no: ‘, d); readln end.
uses crt; var n,i,max,vt:longint; a:array[1..100]of longint; begin clrscr; readln(n); max:=a[1]; for i:=1 to n do readln(a[i]); for i:=2 to n do if a[i]>max then begin max:=a[i]; vt:=i end; writeln(‘Max: ‘,max); writeln(‘Chi so ‘,max,’: ‘,vt); readln; end.
program hama;
uses crt;
var A: array[1..500] of integer;
i, n, max, d: integer;
begin
clrscr;
write(‘Nhap n = ‘); readln(n);
for i:=1 to n do
begin
write(‘A[‘, i, ‘] = ‘); readln(A[i]);
end;
max:=A[1];
for i:=1 to n do if max<A[i] then
begin
max:=A[i];
d:=i;
end;
writeln(‘So hang lon nhat: ‘, max);
write(‘Chi so cua no: ‘, d);
readln
end.
uses crt;
var n,i,max,vt:longint; a:array[1..100]of longint;
begin
clrscr;
readln(n);
max:=a[1];
for i:=1 to n do readln(a[i]);
for i:=2 to n do
if a[i]>max then begin max:=a[i]; vt:=i end;
writeln(‘Max: ‘,max);
writeln(‘Chi so ‘,max,’: ‘,vt);
readln;
end.