Những câu hỏi liên quan
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)
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)
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)
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)
Magic_Kaitosan Magic
Xem chi tiết
Phan thị lê na
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:40

1:

uses crt;

var a:array[1..100]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:42

3:

const fi='dl.txt'

fo='kq.txt'

var f1,f2:text;

a:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a);

writeln(f2,a);

close(f1);

close(f2);

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:41

2:

uses crt;

var st:string;

d: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;

writeln(st);

readln;

end.

Bình luận (0)
Ma Thị Ánh Nguyệt
Xem chi tiết
Lê Chiêu Nguyên	Vũ
Xem chi tiết