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.
*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.
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.
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;
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] in ['a'..'z'] then upcase(st[i]);
writeln(st);
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;
i,d:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
begin
if st[i]=' ' then writeln
else write(st[i]);
end;
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,s:string;
i,d,dem,kt,j,dem1:integer;
begin
clrscr;
write('Nhap xau:'); readln(s);
writeln('Xau vua nhap la: ',s);
d:=length(s);
for i:=1 to d do
if s[i]=#32 then delete(s,i,1);
dem:=1;
st[1]:=s[1];
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if s[i]=st[j] then kt:=1;
if kt=0 then
begin
inc(dem);
st[dem]:=s[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to d do
if st[i]=s[j] then inc(dem1);
writeln(st[i],' xuat hien ',dem1,' lan');
end;
readln;
end.
Cách 1: Có sử dụng
uses crt;
var st:string;
{---------------------------chuong-trinh-con--------------------------}
procedure cd(var s:string);
var i,d:integer;
begin
d:=length(s);
for i:=1 to d do
s[i]:=upcase(s[i]);
for i:=1 to d do
write(s[i]);
end;
{--------------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
cd(st);
readln;
end.
Cách 2: Không sử dụng
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
for i:=1 to d do
write(st[i]);
readln;
end.