Câu 1:
uses crt;
var st:string;
d,i,dem:integer;
begin
clrscr;
write('Nhap xau ki tu:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]='H' then inc(dem);
writeln('Trong xau co ',dem,' ki tu H');
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of longint;
n,i,t,kt,j:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
Until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<a[i]) and (a[i]<60000);
end;
{-----------------------------cau-a-------------------------}
Writeln('Nhung so chan trong day la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
Writeln;
{------------------------cau-b----------------------------}
t:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then t:=t+a[i];
end;
Writeln('Tong cac so nguyen to co trong day la: ',t);
readln;
end.