Viết chương trình đọc 1 xâu từ tệp Xau.mp. Kiểm tra trong xâu có bao nhiêu kí tự ‘a’. Kết quả ghi vào tệp KQ.Out
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
const fi='vao.inp';
fo='ra.out';
var f1,f2:text;
st:string;
i,d:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,st);
d:=length(st);
for i:=1 to d do
if st[i]='a' then delete(st,i,1);
writeln(f2,st);
close(f1);
close(f2);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
const fi='dl.inp';
fo='dl.out';
var f1,f2:text;
st:string;
i,d:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,st);
d:=length(st);
for i:=2 to d-1 do
write(f2,st[i]);
close(f1);
close(f2);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
const fi='demxau.inp',
fo='demxau.out';
var f1,f2:text;
st:string;
d,i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]=' ' then dem:=dem+1;
writeln(f2,dem+1);
close(f1);
close(f2);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 1:
uses crt;
var st:string;
d,i,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
write('Xau sau khi xoa so la: ');
for i:=1 to d do
if not(st[i] in ['0'..'9']) then write(st[i]);
writeln;
dem:=0;
for i:=1 to d do
if st[i]=#32 then inc(dem);
writeln('Xau co ',dem,' dau cach');
writeln('Do dai cua xau la: ',d);
readln;
end.
Câu 2:
uses crt;
const fi='kq.out';
var st1,st2:string;
f1:text;
begin
clrscr;
write('Nhap xau thu 1:'); readln(st1);
write('Nhap xau thu 2:'); readln(st2);
assign(f1,fi); rewrite(f1);
if length(st2)>length(st1) then writeln(f1,st2)
else writeln(f1,st1);
close(f1);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Program HOC24;
const fi='DL.INP';
fo='DL.OUT';
var s: string;
d,i: byte;
f: text;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,s);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
d:=0;
for i:=1 to length(s) do if s[i] in ['0'..'9'] then inc(d);
write(f,d);
close(f);
end;
begin
ip;
out;
end.
const fi='dl.inp';
fo='kq.out';
var f1,f2:text;
s:string;
d,i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,s);
d:=length(s);
dem:=0;
for i:=1 to d do
if s[i] in ['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
Program HOC24;
var s: string;
i,d: byte;
f1,f2: text;
fi='Xau.mp';
fo='KQ.Out';
begin
assign(f1,fi);
assign(f2,fo);
reset(f1);
rewrite(f2);
readln(f1,s);
d:=0;
for i:=1 to length(s) do if s[i]='a' then d:=d+1;
write(f2,d);
close(f1); close(f2);
end.