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.
Program HOC24;
var i,d1,d2: byte;
st1,st2: string[60];
begin
write('Nhap xau st1: '); readln(st1);
//---------------Câu 1-------------------
d1:=0; d2:=0;
for i:=1 to length(st1) do
begin
if st1[i]='A' then d1:=d1+1;
if st1[i]='a' then d2:=d2+1;
end;
writeln('Co ',d1,' ki tu A trong xau');
writeln('Co ',d2,' ki tu a trong xau');
//---------------------- Câu 2 --------------------
st2:='';
for i:=1 to length(st1) do if st1[i] in ['a'..'z'] then st2:=st2+st1[i];
writeln('Xau st2 la: ',st2);
//------------------------------Câu 3--------------------
for i:=1 to length(st1) do st1[i]:=upcase(st1[i]);
write('Xau st1 sau khi in hoa la: ',st1);
//--------------------------------------------------------
readln
end.
program stringManipulation;
var
st1, st2: string;
countN, i: integer;
begin
write('Nhap vao xau ki tu st1: ');
readln(st1);
countN := 0;
for i := 1 to length(st1) do
begin
if (st1[i] = 'N') or (st1[i] = 'n') then
begin
countN := countN + 1;
end;
end;
writeln('So ky tu N va n trong xau st1 la: ', countN);
st2 := '';
for i := 1 to length(st1) do
begin
if (st1[i] >= 'A') and (st1[i] <= 'Z') then
begin
st2 := st2 + st1[i];
end;
end;
writeln('Cac ky tu in hoa trong xau st1 la: ', st2);
write('Xau st1 viet theo chieu nguoc lai la: ');
for i := length(st1) downto 1 do
begin
write(st1[i]);
end;
readln;
end.
st1 = input("Nhập vào xâu kí tự: ")
count_n = 0
st2 = ""
for char in st1:
if char == 'N' or char == 'n':
count_n += 1
if char.isupper():
st2 += char
print("Số lần xuất hiện của kí tự 'N' và 'n' là:", count_n)
print("Xâu kí tự chỉ chứa kí tự in hoa là:", st2)
print("Xâu kí tự đảo ngược là:", st1[::-1])
2:
uses crt;
var st:string;
d,i,dem1,dem2:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
dem1:=0;
dem2:=0;
for i:=1 to d do
begin
if st[i] in ['0'..'9'] then inc(dem1);
if (st[i] in ['a'..'z']) or (st[i] in ['A'..'Z']) then inc(dem2);
end;
writeln('So ki tu la chu so la: ',dem1);
writeln('So ki tu la chu cai la: ',dem2);
for i:=1 to d do
if st[i] in ['0'..'9'] then delete(st,i,1);
writeln('Xau sau khi xoa cac chu so la: ',st);
readln;
end.
Bài 1:
uses crt;
var S:String;
vt:integer;
begin
clrscr;
Write(‘Nhap 1 xau:’); Readln(S);
While pos(‘nang’,s)>0 do
Begin
Vt:= pos(‘nang’,s);
Delete(s,vt,4);
Insert(‘mua’,s ,vt);
End;
Writeln(‘Xau sau khi thay the ’,s);
Readln;
End.
Bài 2:
uses crt;
var st:string;
d,i,kt:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
kt:=0;
for i:=1 to d do
if st[i]<>st[d-i+1] then kt:=1;
if kt=0 then writeln(st,' la xau doi xung')
else writeln(st,' khong la xau doi xung');
readln;
end.
uses crt;
var s:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau S:'); readln(s);
d:=length(s);
writeln('Cac ki tu so co trong xau S:');
dem:=0;
for i:=1 to d do
if s[i] in ['0'..'9'] then
begin
write(s[i]:4);
inc(dem);
end;
writeln;
writeln('So ki tu chu so co trong xau S: ',dem);
for i:=1 to d do
if s[i] in ['0'..'9'] then s[i]:='A';
writeln('Xau sau khi doi la: ',s);
readln;
end.
Program Xau;
Uses crt;
Var St: String;
i: longint;
Begin
Clrscr;
Write('Nhap xau: '); Readln(St);
For i:=1 to length(St) do
St[i] := Upcase(St[i]);
Write('St = ',St);
Readln
End.
Program HOC24;
var s: string;
i: byte;
begin
write('Nhap xau :'); readln(s);
for i:=1 to length(s) do if s[i]<>'a' then write(s[i]);
readln
end.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]='a' then delete(st,i,1);
writeln(st);
readln;
end.
uses crt;
var st:string;
a:array[1..255]of string;
i,d,dem,kt,j,dem1:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
a[1]:=st[1];
dem:=1;
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if st[i]=a[j] then kt:=1;
if kt=0 then
begin
inc(dem);
a[dem]:=st[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to d do
if a[i]=st[j] then inc(dem1);
writeln(a[i],' xuat hien ',dem1,' lan');
end;
readln;
end.
uses crt;
var a:string;
c:char;
i,dem:integer;
begin
clrscr;
readln(a);
readln(c);
dem:=0;
for i:=1 to length(a) do
if a[i]=c then dem:=dem+1;
writeln(dem);
readln;
end.
Program HOC24;
var i,d: byte;
s: string;
begin
write('Nhap xau: '); readln(s);
d:=0;
for i:=1 to length(s) do
if s[i]='b' then d:=d+1;
writeln('Co ',d,' ki tu b');
write('Xau moi sau khi da xoa la: ');
for i:=1 to length(s) do if s[i]<>'b' then write(s[i]);
readln
end.