0 bình luận về “Nhập vào xâu S, đếm số kí tự ‘a’ trong xâu.”
uses crt; var s:string; i,dem:byte; begin clrscr; write(‘Nhap s: ‘); readln(s); for i:=1 to length(s) do if s[i]=’a’ then inc(dem); if dem=0 then write(‘Khong co ky tu a trong xau’) else write(‘Co ‘,dem,’ ki tu a trong xau’); readln end.
program oken; uses crt; var s: string; i,dem:byte; begin clrscr; write(‘Nhap 1 xau bat ky: ‘); readln(s); dem:=0; for i:=1 to length(s) do if (s[i]=’a’) then dem:=dem+1; if dem<>0 then writeln(‘Co ‘,dem,’ ki tu a trong xau.’) else writeln(‘Khong co ki tu a nao trong xau.’); readln; end.
uses crt;
var s:string;
i,dem:byte;
begin
clrscr;
write(‘Nhap s: ‘); readln(s);
for i:=1 to length(s) do
if s[i]=’a’ then inc(dem);
if dem=0 then write(‘Khong co ky tu a trong xau’)
else write(‘Co ‘,dem,’ ki tu a trong xau’);
readln
end.
program oken;
uses crt;
var s: string;
i,dem:byte;
begin
clrscr;
write(‘Nhap 1 xau bat ky: ‘); readln(s);
dem:=0;
for i:=1 to length(s) do
if (s[i]=’a’) then
dem:=dem+1;
if dem<>0 then
writeln(‘Co ‘,dem,’ ki tu a trong xau.’)
else
writeln(‘Khong co ki tu a nao trong xau.’);
readln;
end.