[r]
(1)Program bt1;
Var A: array[1 10] of integer; i, max, sc , t: integer; Begin
Write(‘ nhap cac phan tu cua day :’); For i:=1 to 10 do
Begin
Write(‘nhap pt thu ’,i,’=’); Readln(A[i]);
End;
max:=A[1]; For i:=2 to 10 do
If A[i] > max then max:=A[i]; writeln(‘gtri ptu max=’,max);
sc:=0;
For i:=1 to 10 do
if A[i] mod =0 then sc:=sc + 1; writeln(‘so luong so chan=’,sc);
writeln(‘so luong so le=’, 10 - sc); t:=0;
For i:=1 to 10 do t:= t + A[i];
writeln(‘ gia tri trung binh cua cac phan tu mang=’, t/10:10:4); readln
end.
-Program bt2;
var a,b,c:array[1 15] of integer; i, j, k : integer;
begin
for i:=1 to 15 begin
write('nhap gia tri cho tu thu ',i,':'); readln(a[i]);
end;
j:=0 ; k:=0; for i:=1 to 15
if a[i] mod = then begin
j:=j+1; b[j]:=a[i]; end
else begin k:=k+1; c[k]:=a[i]; end;
(2)for i:=1 to j write(b[i]:4);
writeln('mang cac so le'); for i:=1 to k
write(c[i]:4); readln
end
-Program bt3;
var a:array[1 5,1 8] of integer; i, j, tb, tc, slb, slc : integer; begin
Writeln (‘ Nhap cac phan tu cua mang : ’ ); For i := to
For j := to Readln(a[i , j] ); tb:=0; slb:=0 ;
for i:=1 to for j:=1 to
if j mod <> then begin
tb:= tb+a[i,j]; slb:= slb+1; end;
writeln('trung binh cong ptu cot le: ', tb/slb:10:2); tc:= 0; slc:= ;
for i:=1 to for j:=1 to
if (i mod = 0) and (j mod <> 0) then begin
tc:= tc+a[i,j]; slc:= slc+1; end;
writeln('trung binh cong ptu dong chan, cot le: ', tc/slc:10:2); readln
end
-Program bt4;
Var B : Array[1 5,1 7] of integer; i, j, k: integer;
Begin
Write (‘ Nhap cac phan tu cua mang theo dong: ’ ); For i := to
(3)Write(‘Nhap vao gia tri k=’); readln(k); For i := to
For j := to If B[i, j] < k Then Write(B[i, j], ‘ ’ ); Readln
End
-Program bt5;
var s:string; i:byte;
procedure nhapxau; begin
write('Nhap xau s:'); readln(s);
end;
function inhoa:string; begin
for i:=1 to length(s) s[i]:=upcase(s[i]); inhoa:=s;
end;
procedure sotu; var dem: byte; begin
s:=' '+s; dem:=0;
for i:=2 to length(s)
if (s[i-1]=' ') and (s[i]<>' ') then dem:=dem+1; writeln('so tu cau la:',dem,' tu');
end; begin nhapxau;
writeln('xau in hoa:',inhoa); sotu;
readln; end
-Program bt6;
var s:string; vt:integer; begin
write('nhap xau :'); readln(s);
(4)begin
vt:= pos('anh',s); delete(s,vt,3); insert('em',s,vt); end;
writeln('xau da thay the :',s); readln
end
-Program bt7;
var a,b,c,d,e:integer;
function max(a,b: integer): integer; begin
if a> b then max:=a else max:=b;
end; begin
write('nhap so:'); readln(a,b,c,d,e);
writeln('so lon nhat so: ', max(max(max(max(a,b),c),d),e)); readln
end
-program bt8;
var s1,s2:string; x,y:integer; begin
write('nhap xau 1:'); readln(s1);
write('nhap xau 2:'); readln(s2);
x:=length(s1); y:=length(s2);
writeln(' dai cua xau 1:',x); writeln(' dai cua xau 1:',y);
if s1[1] = s2[y-1] then write('trung nhau' ) else write('khac nhau' );
readln end
-Program bt9;
Var a,b,c:integer;
function tbc(a,b,c:integer) : real; begin
tbc:=(a+b+c)/3; end;
function min(a,b:integer) : integer; begin
if a < b then min:= a else min:= b
(5)begin
write('nhap gia tri cho so nguyen :'); readln(a,b,c);
writeln('tbc cua so nguyen :',tbc(a,b,c):10:2);
writeln('so nho nhat so nguyen :', min(min(a,b),c)); readln