Những câu hỏi liên quan
Nguyễn An
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 7 2021 lúc 14:32

uses crt;

var s,s1,s2:string;

i,d:integer;

begin

clrscr;

readln(s);

s1:=''

s2:=''

d:=length(s);

for i:=1 to d do

  begin

if s[i] in ['0'..'9'] then s1:=s1+s[i];

if (s[i] in ['a'..'z']) or (s[i] in ['A'..'Z']) then s2:=s2+s[i];

end;

writeln('Xau chua cac ki tu so la: ',s1);

writeln('Xau chua cac ki tu chu la: ',s2);

readln;

end.

Bình luận (0)
Do Ngoc Thao My
Xem chi tiết
Do Ngoc Thao My
Xem chi tiết
Long ca ca
Xem chi tiết
Long ca ca
20 tháng 8 2023 lúc 19:18

Làm bằng pascal nha

 

Bình luận (0)
Long ca ca
Xem chi tiết
Phía sau một cô gái
21 tháng 8 2023 lúc 20:49

program XoaSoLienTuc;

uses sysutils;

function XoaSoLienTuc(S: string): string;

var

     i: integer;

     result: string;

begin

     result := ''

     for i := 1 to Length(S) do

     begin

          if not (S[i] in ['0'..'9']) then

          begin

               if (i = 1) or (S[i-1] in ['0'..'9']) then

                    result := result + ' '

               result := result + S[i];

          end;

     end;

     result := Trim(result);

     result := StringReplace(result, ' ', '', [rfReplaceAll]);

     XoaSoLienTuc := result;

end;

var

     S: string;

begin

     write('Nhập vào xâu S: ');

     readln(S);

     writeln('Kết quả: ', XoaSoLienTuc(S));

end.

Bình luận (1)
Ánh Nguyệt Thiên Vĩ
Xem chi tiết
phạm tú
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 3 2023 lúc 14:29

#include <bits/stdc++.h>

using namespace std;

int main()

{

string st;

int d,i,dem=0;

getline(cin,st);

d=st.length();

for (int i=0; i<d; i++)

if (st[i]=' ') dem++;

cout<<dem+1;

return 0;

}

Bình luận (0)
Nguyễn Thị Hòa
Xem chi tiết
Anh Phạm
25 tháng 7 2021 lúc 20:51

uses crt;

var s:string;

i,tong,x,code:integer;

f,g:text;

k:boolean;

const fi='XAU.INP'

          fo='XAU.OUT'

begin

k:=false;

assign(f,fi); reset(f);

assign(g,fo); rewrite(g);

readln(f,s);

tong:=0;

for i:=1 to length(s) do

begin

if s[i] in ['0'..'9'] then

begin

k:=true;

val(s[i],x,code);

tong:=tong+x;

x:=0;

cod:=0;

end;

end;

if k=false then writeln(g,'Sai yeu cau')

else

begin

writeln(g,s);

writeln(g,tong);

end;

close(f);

close(g);

end.

Bình luận (0)
Hiếu
Xem chi tiết
Nguyễn Lê Phước Thịnh
29 tháng 3 2021 lúc 21:36

uses crt;

var s:string;

i,d,dem:integer;

begin

clrscr;

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

d:=length(s);

writeln('Cac ki tu so co trong xau S:'); 

dem:=0;

for i:=1 to d do 

  if s[i] in ['0'..'9'] then

begin

write(s[i]:4);

inc(dem);

end;

writeln;

writeln('So ki tu chu so co trong xau S: ',dem);

for i:=1 to d do 

  if s[i] in ['0'..'9'] then s[i]:='A'

writeln('Xau sau khi doi la: ',s);

readln;

end.

Bình luận (0)