Giả sử trong ổ đĩa E có một tệp tên DKT, bên trong tệp DKT chứa một dãy ký tự chữ hoa. Các bạn hãy viết chương trình đưa ra màn hình xâu ký tự đó với chữ thường.
Viết chương trình đọc dữ liệu từ tệp Input.txt chứa một xâu có độ dài không quá 125 ký tự .Cho biết số lần xuất hiện của mỗi chữ cái Tiếng Anh trong xâu đã đọc được ( không phân chữ hoa thường). Ghi kết quả ra tệp Output.txt
const fi='input.txt'
fo='output.txt'
var f1,f2:text;
st:string[125];
a:array[1..125]of string;
i,d,dem,kt,j:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,st);
d:=length(st);
dem:=1;
a[1]:=st[1];
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if a[j]=st[i] then kt:=1;
if kt=0 then
begin
inc(dem);
a[dem]:=st[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to d do
if a[i]=st[j] then inc(dem1);
writeln(f2,a[i],' xuat hien ',dem1,' lan');
end;
close(f1);
close(f2);
end.
Đọc từ tệp ‘xau.đặt’ ra 1 xâu ký tự s có độ dài tối đa 50 kí tự a, nếu trong xâu có 3 dấu cách thì xoá 2? b, chuyển các ký tự trong xâu thành in hoa? c, đếm các chữ số có trong xâu? Đưa các kết quả ra màn hình?
Viết chương trình nhập vào một xâu gồm các ký tự là mẫu tự thường, hoa và các chữ số từ bàn phím. Chương trình thực hiện các công việc sau:
a. Xuất ra dãy chỉ chứa các ký tự là mẫu tự thường và chuyển sang chữ hoa.
b. Xuất ra dãy số chỉ chứa các chữ số đã được đảo ngược.
c. Tìm chữ số lớn nhất trong xâu.
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.
Viết chương trình nhập vào một xâu ký tự S. Xuất xâu đã nhập. Thực hiện chuyển đổi các ký tự thường thành ký tự in hoa có trong sâu S. Xuất xâu S đã chuyển đổi ra màn hình
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.
Viết chương trình nhập vào một xâu ký tự st có độ dài không quá 100. Hãy thay thế các ký tự "a" hoặc "A" thành ký tự "b" trong xâu st. Đưa kết quả ra màn hình.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
readln(st);
d:=length(st);
for i:=1 to d do
if (st[i]='a') or (st[i]='A') then st[i]:='b'
writeln(st);
readln;
end.
Em hãy viết chương trình nhập vào một xâu ký tự bất kỳ từ bàn phím (tối đa 250 kí tự) bao gồm cả chữ hoa, chữ thường và số. Hãy đếm và in ra màn hình:
a, Số các chữ số trong xâu đã cho
b, Số các kí tự in hoa trong xâu đã cho
c, Chuyển hóa toàn bộ xâu thành ký tự hoa và in ra màn hình
giúp em vs ạ em cần gấp
Em hãy viết chương trình nhập vào một xâu ký tự bất kỳ từ bàn phím (tối đa 250 kí tự) bao gồm cả chữ hoa, chữ thường và số. Hãy đếm và in ra màn hình:
a, Số các chữ số trong xâu đã cho
b, Số các kí tự in hoa trong xâu đã cho
c, Chuyển hóa toàn bộ xâu thành ký tự hoa và in ra màn hình
Em hãy viết chương trình nhập vào một xâu ký tự bất kỳ từ bàn phím (tối đa 250 kí tự) bao gồm cả chữ hoa, chữ thường và số. Hãy chuyển hoá xâu vừa nhập thành chữ thường và in ra màn hình.
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.
Viết chương trình nhập vào một xâu chuẩn bất kỳ ký tự thường sau đó hãy xóa hết các ký tự đặc biệt có trong xâu chỉ chứa lại các ký tự từ A đến Z và từ 0 đến 9 và khoảng cách rồi đưa kết quả lên dulieu.txt Giúp e vs ạ
uses crt;
const fi='dulieu.txt'
var f1:text;
st:string;
i,d:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if (st[i] in ['A'..Z']) or (st[i] in ['0'..'9']) or (st[i]=#32) then write(f1,st[i]);
close(f1);
end.