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.
#include <bits/stdc++.h>
using namespace std;
int d,i,d1;
string st;
int main()
{
getline(cin,st);
d=st.length();
while (st[0]==32)
{
st.erase(0,1);
}
while (st[d-1]==32)
{
st.erase(d-1,1);
}
d1=st.length();
for (i=0; i<d1; i++)
if ((st[i]==32) && st[i+1]==32)
{
st.erase(i,1);
i--;
}
cout<<st;
return 0;
}
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Xau vua nhap la: ',st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln('Xau moi la: ',st);
readln;
end.
tham khảo
uses crt;
var a:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau a:'); readln(a);
dem:=0;
d:=length(a);
for i:=1 to d do
if a[i]=' ' then inc(dem);
writeln(dem);
readln;
end.
Cậu tham khảo nhé!!!
https://hoc24.vn/cau-hoi/viet-chuong-trinh-nhap-mot-xau-tu-ban-phim-thay-ky-tu-39a39-thanh-39i39-va-in-xau-da-thay-ra-man-hinh-thay-tat-ca-chu-39anh39-t.257698320219
uses crt;
var s:string;
begin
clrscr;
write('Nhap xau: '); readln(s);
while pos('a',s)<>0 do
begin
insert('i',s,pos('a',s));
delete(s,pos('a',s),1);
end;
write('Xau sau khi chuyen la : ',s);
readln;
end.
Use crt;
Var S : String;
P: longint;
Begin
Write('Nhap s: '); readln (S);
For P:=length(S) downto 1 do
Write(P);
Readln;
End.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Xau ban vua nhap la: ',st);
writeln('Xau nguoc la: ');
for i:=d downto 1 do
write(st[i]:4);
readln;
end.
Chương trình:program bai_10_chuong_4;uses crt;vars: string[100];i, dem: integer;Beginclrscr;write('Nhap xau vao:'); readln(s); dem:= 0;for i:= 1 to length(s) doif ('0'<=s[i]) and(s[i]<=’9') then dem:=dem+l;Writeln('Trong xau s co '»dem,' chu so thap phan');readln;End.
#include <bits/stdc++.h>
using namespace std;
string st;
char ktu;
int dem,i,d;
int main()
{
getline(cin,st);
cin>>ktu;
d=st.length();
dem=0;
for (i=0; i<=d-1; i++)
if (st[i]==ktu) dem++;
cout<<dem;
return 0;
}