Viết chương trình nhập vào ký tự nếu là ký tự thường thì in ra kí tự hoa tương ứng, nếu là kí tự hoa thì in ra kí tự thường tương ứng, nếu là các kí tự khác thì in ra chính nó
(Ai trả lời nhanh mik tick nha)
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.
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if (st[i] in ['a'..'z']) or (st[i] in ['A'..'Z']) then inc(dem);
writeln(dem);
readln;
end.
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.
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.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
if st[i] in ['A'..'Z'] then write(st[i]:4);
readln;
end.
Program HOC24;
var i,d1,d2: byte;
st1,st2: string[60];
begin
write('Nhap xau st1: '); readln(st1);
//---------------Câu 1-------------------
d1:=0; d2:=0;
for i:=1 to length(st1) do
begin
if st1[i]='A' then d1:=d1+1;
if st1[i]='a' then d2:=d2+1;
end;
writeln('Co ',d1,' ki tu A trong xau');
writeln('Co ',d2,' ki tu a trong xau');
//---------------------- Câu 2 --------------------
st2:='';
for i:=1 to length(st1) do if st1[i] in ['a'..'z'] then st2:=st2+st1[i];
writeln('Xau st2 la: ',st2);
//------------------------------Câu 3--------------------
for i:=1 to length(st1) do st1[i]:=upcase(st1[i]);
write('Xau st1 sau khi in hoa la: ',st1);
//--------------------------------------------------------
readln
end.
Var a: string;
i, Dem: integer;
Begin
writeln(‘nhap xau:’);
Readln(a);
Dem:=0;
For i:=1 to length(a) do
If (‘a’<=a[i]) and (a[i]<=’z’)
Dem:= Dem+1;
Writeln(Dem);
Readln
End.
-lệnh dùng để xóa màn hình làm việc:
Uses Crt ; { khai báo thư viện hàm }
Clrscr; { lệnh xóa màn hình kết quả }
- hai lệnh này dùng song song vs nhau nha.
VD:
Program vi_du;
uses crt;
var i,n: integer;
s: real;
begin
clrscr;
write('nhap so n ='); readln(n);
s:=0;
for i:= 1 to n do
s:=s+i;
writeln(s :4:2);
readln;
end.
Program Chuoi_Chu_Thuong;
Uses Crt;
Var i,l:integer;
st:string[50];
Begin
Clrscr;
Writeln(‘DOI CHUOI SANG CHUOI CHU THUONG’);
Write(‘Nhap chuoi ky tu: ‘); Readln(st);
For i:=1 to length(st) do
If (st[i]>=’A’) and (st[i]<='Z') then st[i]:= chr(ord(st[i])+32);
Writeln;
Writeln('Chuoi doi thanh chu thuong la : '); Writeln(st);
Writeln; l:=length(st); st[l]:=upcase(st[l]); For i:=l downto 2 do
If st[i]=' ' then st[i-1]:=upcase(st[i-1]);
Writeln('Chuoi cac ky tu cuoi cua tu la ky tu hoa: ');
Writeln(st);
Readln;
End.