Những câu hỏi liên quan
Văn Hữu
Xem chi tiết
Nguyễn Quốc Đạt
19 tháng 12 2023 lúc 19:54

Program HOC24;

var s: string;

i,x: byte;

begin

readln(s);

//-----------Câu a

while s[1]=#32 do delete(s,1,1);

while s[length(s)]=#32 do delete(s,length(s),1);

while pos(#32#32,s)<>0 do delete(s,pos(#32#32,1);

writeln(s);

//-------------Câu b

s[1]:=upcase(s[1]);

for i:=1 to length(s) do

if s[i]=#32 upcase(s[i+1]);

writeln(s);

//--------------Câu c

for i:=1 to length(s) do

if s[i]=#32 then x:=i;

for i:=x+1 to length(s) do

write(s[i]);

//---------------------------

readln

end.

Bình luận (0)
luc lun
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 12 2021 lúc 23:09

#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;
}

 

Bình luận (1)
Ngô Chí Thành
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 4 2021 lúc 9:29

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.

Bình luận (0)
Ngô Chí Thành
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 4 2021 lúc 9:40

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.

Bình luận (0)
Trần Hải Đăng
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 1 2022 lúc 20:58

#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;
}

 

Bình luận (0)
Magic_Kaitosan Magic
Xem chi tiết
Khánh Mỹ
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2021 lúc 19:45

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.

Bình luận (0)
Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
30 tháng 4 2017 lúc 16:06

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.

Bình luận (0)
Thangg PH
Xem chi tiết
Minh Lệ
3 tháng 4 2021 lúc 18:54

Program HOC24;

var S: string;

d,i: byte;

begin

write('S= '); readln(s);

For i:= length(s) downto 1 do write(s[i]);

writeln;

while s[length(s)]=#32 do delete(s,length(s),1);

while pos(#32#32,s)<>0 do delete(s,pos(#32#32,s),1);

while s[1]=#32 do delete(s,1,1);

d:=0;

for i:=1 to length(s) do d:=d+1;

write('So tu :',d);

readln

end.

Bình luận (1)
Nguyễn Lê Phước Thịnh
3 tháng 4 2021 lúc 19:16

uses crt;

var s:string[200];

i,d,dem:integer;

begin

clrscr;

write('Nhap xau:'); readln(s);

d:=length(s);

write('Xau viet theo chieu nguoc la: ');

for i:=d downto 1 do 

  write(st[i]);

writeln;

dem:=0;

for i:=1 to d do 

  if st[i]=#32 then inc(dem);

writeln('So tu la: ',dem);

readln;

end.

Bình luận (1)