: Viết chương trình nhập một xâu s1 bất kỳ vào từ bàn phím, tạo xâu s2 gồm tất cả các ký tự không phải là chữ số có trong xâu s1 và in kết quả ra màn hình.
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.
program ChuyenXauSangChuThuong;
var
str: string;
i: integer;
begin
write('Nhap mot xau ky tu: ');
readln(str);
for i := 1 to Length(str) do
str[i] := LowerCase(str[i]);
writeln('Xau ky tu chuyen thanh chu thuong la: ', str);
end.
Var s,st:string;
i:integer;
Begin
Write('Nhap xau ');readln(s);
For i:=1 to length(s) do
If s[i] in ['0'..'9'] then st:=st+s[i];
Write('Cac ki tu so co trong day la ',st);
Readln
End.
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.
Chương trình:
program bai_10_chuong_4;
uses crt;
var
s: string[100];
i, dem: integer;
Begin
clrscr;
write('Nhap xau vao:'); readln(s); dem:= 0;
for i:= 1 to length(s) do
if ('0'<=s[i]) and(s[i]<=’9') then dem:=dem+l;
Writeln('Trong xau s co '»dem,' chu so thap phan');
readln;
End.
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Xau vua nhap la: ',st);
dem:=0;
for i:=1 to d do
if st[i] in ['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
if not (st[i] in ['0'..'9']) then write(st[i]);
readln;
end.
uses crt;
var st:string[50];
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i] in ['a'..'z'] then write(st[i]:4);
readln;
end.
:) Bạn nhập tiếng việt thôi nha, không phải là tiếng anh đâu.
Lỗi à!