Câu 1:
procedure nhap(n:integer);
begin
repeat
write('Nhap n='); readln(n);
until n>0;
end;
Câu 2:
uses crt;
var i,n,dem,max:integer;
a,b:array[1..100]of 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 max:=a[i];
dem:=0;
for i:=1 to n do
if (max=a[i]) and (i mod 2=0) then
begin
inc(dem);
b[dem]:=i;
end;
if dem=0 then writeln('Trong day khong co gia tri lon nhat co chi so chan')
else begin
writeln('Cac chi so chan trong day co gia tri lon nhat la: ');
for i:=1 to dem do
write(b[i]:4);
end;
readln;
end.
Câu 3:
uses crt;
var i,n,dem,min:integer;
a,b:array[1..100]of integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
dem:=0;
for i:=1 to n do
if (min=a[i]) and (i mod 2=1) then
begin
inc(dem);
b[dem]:=i;
end;
if dem=0 then writeln('Trong day khong co gia tri nho nhat co chi so le')
else begin
writeln('Cac chi so le trong day co gia tri nho nhat la: ');
for i:=1 to dem do
write(b[i]:4);
end;
readln;
end.
Câu 4:
uses crt;
var st:string;
i,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
for i:=1 to length(st) do
if not(st[i] in ['a'..'z']) then st[i]:=chr(ord(st[i])+32);
dem:=0;
for i:=1 to length(st) do
if copy(st,i,3)='anh' then inc(dem);
writeln('Trong xau co ',dem,' tu anh');
readln;
end.
Câu 1:
Procedure nhap;
var n: integer;
begin
write('n='); readln(n);
end;
Câu 2:
Program HOC24;
var i,n,max: integer;
a: array[1..32000] of integer;
begin
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=0;
for i:=1 to n do
if (i mod 2=0) and (a[i]>max) then max:=a[i];
write('Gia tri max o vi tri chan la : ',max);
readln
end.
Câu 3:
Program HOC24;
var i,n,min: integer;
a: array[1..32000] of integer;
begin
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=2 to n do
if (i mod 2=1) and (a[i]<min) then min:=a[i];
write('Gia tri min o vi tri le la : ',min);
readln
end.
Câu 4:
Program HOC24;
var s: string;
d: byte;
begin
d:=0;
write('Nhap xau : '); readln(s);
while pos('anh',s)<>0 do
begin
inc(d);
delete(s,pos('anh',s),3);
end;
write('So luong tu "anh" trong xau la : ',d);
readln
end.