hãy lập chương trình trên pascal tính số dấu cách trong xâu
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.
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.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
begin
if st[i]=' ' then writeln
else write(st[i]);
end;
readln;
end.
Program hotrotinhoc;
var s: string;
t,c,i: byte;
begin
write('Nhap s:'); readln(s);
t:=0;
for i:=1 to length(s) do
if s[i] in ['1'..'9'] then
begin
val(s[i],c);
t:=t+c;
end;
write(t);
readln
end.
Thu gọn
uses crt;
var st:string;
i,d,t,x,y:integer;
begin
clrscr;
readln(st);
d:=length(st);
t:=0;
for i:=1 to d do
if (st[i] in ['0'..'9']) then
begin
val(st[i],x,y);
t:=t+x;
end;
writeln(t);
readln;
end.
uses crt;
var st:string;
d,i,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
while st[1]=#32 do
begin
delete(st,1,1);
d:=length(st);
end;
while st[d]=#32 do
begin
delete(st,d,1);
d:=length(st);
end;
for i:=1 to d do
begin
while (st[i]=#32) and (st[i+1]=#32) do
begin
delete(st,i,1);
d:=length(st);
end;
end;
st[1]:=upcase(st[1]);
for i:=1 to d do
if st[i]=#32 then st[i+1]:=upcase(st[i+1]);
writeln('Ten cua ban sau khi viet dung la: ',st);
dem:=1;
for i:=1 to d do
if st[i]=#32 then inc(dem);
writeln('So tu cua xau la: ',dem);
readln;
end.
Uses crt;
Var st:string;
I,d:integer;
Begin
Clrscr;
Write('nhap xau:'); readln(st);
D:=length(st);
While st[d]=#32 do
Begin
Delete(st,d,1);
D:=length(st);
End;
For i:=1 to d do
If (st[i]=#32) and (st[i+1]=#32) then delete(st,i,1);
Writeln(st);
Readln;
End.
Uses crt;
Var st:string;
I,d:integer;
Begin
Clrscr;
Write('nhap xau:'); readln(st);
D:=length(st);
While st[d]=#32 do
Begin
Delete(st,d,1);
D:=length(st);
End;
For i:=1 to d do
If (st[i]=#32) and (st[i+1]=#32) then delete(st,i,1);
Writeln(st);
Readln;
End.
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)
uses crt;
var st:string;
d,i,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('So dau cach trong xau la: ',dem);
readln;
end.