Viết chương trình nhập vào 1 xâu bất kì a) thông báo ra màn hình số lượng dấu cách có trong xâu b) thay tất cả dấu cách có trong xâu thành dấu gạch nối c) in ra xâu ngược lại
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)
Program HOC24;
var s: string;
i: byte;
begin
write('Nhap xau: '); readln(s);
for i:=1 to length(s) do if (s[i]<>#32) and (s[i] in 'A'..'z') then
begin
upcase(s[i]); write(s[i]);
end;
readln
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
1:
uses crt;
const fi='ketqua.txt';
var f1:text;
st:string;
i,d:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(f1,st);
close(f1);
end.
2:
uses crt;
var a,b,c,d:integer;
{----------chuong-trinh-con-----------------------}
function min(x,y:integer):integer;
begin
if x<y then min:=x
else min:=y;
end;
{---------------chuong-trinh-chinh--------------------}
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
write('d='); readln(d);
writeln(min(a,min(b,min(c,d))));
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Var a: string;
i, Dem: integer;
Begin
writeln(‘nhap xau:’);
Readln(a);
Dem:=0;
For i:=1 to length(a) do
If a[i] =’ ‘ then
Dem:= Dem+1;
Writeln(Dem);
Readln
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
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.
![](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)
#include <bits/stdc++.h>
using namespace std;
string a,b;
void replaceSubstring(string& a, const string& b) {
size_t pos=0;
while((pos=a.find(b,pos))!=string::npos) {
a.replace(pos,b.length(),"ABC");
pos+=3;
}
}
int main()
{
cin>>a>>b;
if(a.find(b)!=string::npos){
cout<<"YES"<<endl;
replaceSubstring(a,b);
cout<<a;
}else{
cout<<"NO"<<endl;
cout<<a;
}
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
xau = input('Nhap chuoi: ')
so_khoang_cach = xau.count(' ')
print('So khoang cach:', so_khoang_cach)
vi_tri = []
for i in range(len(xau)):
if xau[i] == ' ':
vi_tri.append(i)
print('Vi tri khoang cach:', vi_tri)
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]=#32 then inc(dem);
writeln(dem);
readln;
end.
Mn giúp vs