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.
Cách 1: Có sử dụng chương trình con
uses crt;
var st:string;
{------------chuong-trinh-con-------------------}
function doi(st1:string):string;
var i,d:integer;
begin
d:=length(st1);
for i:=1 to d do
st1[i]:=upcase(st1[i]);
doi:=st1;
end;
{-------------------chuong-trinh-chinh--------------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
writeln(doi(st));
readln;
end.
Cách 2: Không sử dụng chương trình con
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
writeln(st);
readln;
end.
Program HOC24;
var s: string;
i: byte;
begin
write('Nhap xau :'); readln(s);
for i:=1 to length(s) do if s[i]<>'a' then write(s[i]);
readln
end.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]='a' then delete(st,i,1);
writeln(st);
readln;
end.
uses crt;
var st:string;
begin
clrscr;
readln(st);
delete(st,3,5);
writeln(st);
readln;
end.
Program HOC24;
var s: string;
tg,d,max,i: byte;
code: integer;
begin
write('Nhap xau : '); readln(s);
// cau a
for i:=1 to length(s) do if s[i] in ['a'..'z'] then write(upcase(s[i]));
//------
writeln;
//-cau b
for i:=length(s) downto 1 do if s[i] in ['0'..'9'] then write(s[i]);
//------
writeln;
//---cau c
d:=0;
for i:= 1 to length(s) do
if s[i] in ['0'..'9'] then
begin
val(s[i],tg,code);
if tg>max then max:=tg;
d:=d+1;
end;
if d=0 then write('Khong co chu so trong day') else write('Chu so lon nhat la : ',max);
readln
end.
uses crt;
var st,st1:string;
d,i,d1,max,x,y:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Day cac ki tu thuong doi sang chu hoa la: ');
for i:=1 to d do
if st[i] in ['a'..'z'] then write(upcase(st[i]):4);
st1:='';
for i:=1 to d do
if st[i] in ['0'..'9'] then st1:=st1+st[i];
d1:=length(st1);
for i:=d1 downto 1 do
write(st1[i]:4);
writeln;
max:=0;
for i:=1 to d1 do
begin
val(st1[i],x,y);
if max<x then max:=x;
end;
writeln('Chu so lon nhat trong xau la: ',max);
readln;
end.
Chương trình:program bai_10_chuong_4;uses crt;vars: string[100];i, dem: integer;Beginclrscr;write('Nhap xau vao:'); readln(s); dem:= 0;for i:= 1 to length(s) doif ('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;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if not(st[i] in ['a'..'z']) and not(st[i] in ['A'..'Z']) then write(st[i]);
readln;
end.
*Cách có sử dụng chương trình con:
uses crt;
var st:string;
{--------------chuong-trinh-con---------------}
function doixau(st:string):string;
var i,d:integer;
begin
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
doixau:=st;
end;
{-------------chuong-trinh-chinh---------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
writeln('Xau doi sang chu hoa la: ',doixau(st));
readln;
end.
*Cách không sử dụng chương trình con:
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
writeln('Xau sau khi doi la: ',st);
readln;
end.