Cho tệp XAU.TXT chứa 1 xâu ký tự
Viết chương trình đọc dữ liệu từ tệp XAU.TXT ra xâu S
Kiểm tra xâu S có là xâu đối xứng ?
M.n ai bt chỉ giúp e với
Viết chương trình đọc dữ liệu từ tệp fi với tệp fi chứa dữ liệu là 1 xâu dữ liệu. Ghi kết quả vào tệp fo các kết quả sau khi xử lý xâu.
a. Xâu vừa đọc được từ tệp fi, xâu chuyển thành chữ in hoa
b. Xâu s1 được tạo gồm n kí tự liên tiếp của xâu s bắt đầu tại vt.
c. Xâu sau khi xóa a kí tự của xâu s bắt đầu tại vị trí vt
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.
Viết chương trình đọc xâu dữ liệu từ tệp vào vào. Xóa các kí tự ‘a’ trong xâu và in xâu sau khi đã xóa ra tệp kết quả
const fi='vao.inp'
fo='ra.out'
var f1,f2:text;
st:string;
i,d:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,st);
d:=length(st);
for i:=1 to d do
if st[i]='a' then delete(st,i,1);
writeln(f2,st);
close(f1);
close(f2);
end.
Viết chương trình đọc dữ liệu từ tệp Input.Txt 2 xâu. Viết kết quả vào tệp output.Txt xâu nào ngắn hơn. Nếu 2 xâu bằng nhau thì viết thông báo: “2 xâu bằng nhau”
Viết chương trình cho 1 xâu kí tự, hãy kiểm tra tính đối xứng của nó.
gthik: xâu đối xứng là xâu đọc từ trái sang phải hay ngược lại là như nhau.
Input: chứa 1 xâu S
Output: in ra YES nếu S là xâu đối xứng ngược lại in ra NO.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string st;
int dai,i,kt;
cout<<"Nhap chuoi:"; getline(cin,st);
dai=st.length();
kt=0;
for (int i=0;i<dai;i++)
if (st[i]!=st[dai-i-1]) kt=1;
if (kt==0) cout<<"YES";
else cout<<"NO";
return 0;
}
Cho tệp văn bản có tên DATA2.TXT chứa một xâu bất kì không quá 255 kí tự gồm các chữ và số. Viết chương trình đọc xâu kí tự S từ từ tệp DATA2.TXT sau đó ghi dữ liệu là các thông tin sau vào tệp KQ2.TXT:
- Dòng 1: Số lần xuất hiện của kí tự "k" trong xâu?
- Dòng 2: Số lượng kí tự là số xuất hiện trong S (giữ nguyên thứ tự xuất hiện)?
Cho tệp văn bản có tên DATA2.TXT chứa một xâu bất kì không quá 255 kí tự gồm các chữ và số. Viết chương trình đọc xâu kí tự S từ từ tệp DATA2.TXT sau đó ghi dữ liệu là các thông tin sau vào tệp KQ2.TXT:
- Dòng 1: Số lần xuất hiện của kí tự "k" trong xâu?
- Dòng 2: Số lượng kí tự là số xuất hiện trong S (giữ nguyên thứ tự xuất hiện)?
Cho tệp văn bản có tên DATA2.TXT chứa một xâu bất kì không quá 255 kí tự gồm các chữ và số. Viết chương trình đọc xâu kí tự S từ từ tệp DATA2.TXT sau đó ghi dữ liệu là các thông tin sau vào tệp KQ2.TXT:
- Dòng 1: Số lần xuất hiện của kí tự "k" trong xâu?
- Dòng 2: Số lượng kí tự là số xuất hiện trong S (giữ nguyên thứ tự xuất hiện)?
Help me!!! Mai mk thi ạ
Cho tệp văn bản có tên DATA2.TXT chứa một xâu bất kì không quá 255 kí tự gồm các chữ và số. Viết chương trình đọc xâu kí tự S từ từ tệp DATA2.TXT sau đó ghi dữ liệu là các thông tin sau vào tệp KQ2.TXT:
- Dòng 1: Số lần xuất hiện của kí tự "k" trong xâu?
- Dòng 2: Số lượng kí tự là số xuất hiện trong S (giữ nguyên thứ tự xuất hiện)?