Viết chương trình từ tệp BCNN.inp và ghi kết quả ra tệp BCNN.out
mọi ngưới giúp mình với, mình sắp kiểm tra rồi mà không biết làm. Mong mọi người giúp đỡ ạ !
Cho tệp BAIKT.INP chứa các số nguyên bất kì. Viết chương trình đếm xem trong tệp có bao nhiêu số lẻ rồi ghi kết quả vào tệp KETQUA.OUT giúp mình với mình đang gấp ạ. Mình cảm ơn nhiềuu
Cho tệp dulieuvao txt chứa dãy số nguyên viết chương trình đọc dãy số đó,sắp xếp thành tăng dần rồi ghi kết quả đó vào dulieura txt
ai có thể giúp mình được không ạ
Lập trình đọc số nguyên dương N vào tệp có tên ‘Dulieu.txt’ Tính tổng các số chẵn từ 1 đến N, kết quả ghi ra tệp ‘ Uot.txt’ Mọi người giúp em gấp với ạ!!!!!! Em cảm ơn!
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
freopen("dulieu.txt","r",stdin);
freopen("uot.txt","w",stdout);
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t+=i;
cout<<t;
return 0;
}
Viết chương trình đọc 1 xâu từ tệp Xau.mp. Kiểm tra trong xâu có bao nhiêu kí tự ‘a’. Kết quả ghi vào tệp KQ.Out
Program HOC24;
var s: string;
i,d: byte;
f1,f2: text;
fi='Xau.mp'
fo='KQ.Out'
begin
assign(f1,fi);
assign(f2,fo);
reset(f1);
rewrite(f2);
readln(f1,s);
d:=0;
for i:=1 to length(s) do if s[i]='a' then d:=d+1;
write(f2,d);
close(f1); close(f2);
end.
Bài: CHECKNTO Sử dụng hàm viết chương trình kiểm tra N có phải là số nguyên tố N không (N là số nguyên dương; N ≤ 109 ). Dữ liệu vào: Từ tệp văn bản CHECKNTO.INP gồm • Một số nguyên N Kết quả: Ghi ra tệp văn bản CHECKNTO.OUT Ghi ra “YES” nếu N là số nguyên tố hoặc ghi “NO” nếu N không phải là số nguyên tố.
#include <bits/stdc++.h>
using namespace std;
long long n,i;
bool kt;
int main()
{
freopen("checknto.inp","r",stdin);
freopen("checknto.out","w",stdout);
cin>>n;
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true && n>1) cout<<"YES";
else cout<<"NO";
return 0;
}
Viết đoạn văn khoảng 15 dòng kết hợp 3 phương thức biểu cảm, miêu tả và tự sự kể về 1 việc làm tốt góp phần vào việc phòng chống dịch covid mà em đã làm được hoặc em biết ( mọi người ơi giúp mình với mình sắp kiểm tra rồi )
1. Viết chương trình nhập vào 2 số nguyên a và b từ bàn phím. Tính tổng của 2 số đó và ghi kết quả tổng vào tệp Ketqua.txt trong ổ E:\ .
2. Viết chương trình đọc 2 số nguyên từ tệp dulieu.txt trong ổ E:\ . Sau đó, tính tổng của 2 số và xuất kết quả tổng ra màn hình Pascal
Mong mọi người ráng giúp đỡ em ạ , em cảm ơn mọi người nhiều
Bài 1:
uses crt;
const fi='ketqua.txt';
var f1:text;
a,b,t:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('a='); readln(a);
write('b='); readln(b);
t:=a+b;
writeln(f1,t);
close(f1);
readln;
end.
Bài 2:
uses crt;
const fi='dulieu.txt';
var f1:text;
a,b,t:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,a,b);
t:=a+b;
writeln('tong cua hai so la: ',t);
close(f1);
readln;
end.
Mng giúp mình các BT cuối kì vs ạ Bài 1: Viết chương trình nhập từ bàn phím 2 số nguyên a,b; Sau đó ghi chúng vào tệp có tên D:\Baitaptin.txt. Bài 2: Viết chương trình nhập từ bàn phím 1 xâu không quá 180 kí tự; Xuất xâu vừa nhập ra màn hình rồi ghi xâu đó vào tệp có tên E:\tepxau.txt. Bài 3: Viết chương trình nhập từ bàn phím 2 số nguyên dương; Tính và ghi tổng của chúng vào tệp có tên ‘teptong.txt’ rồi xuất tổng ra màn hình.
Bài 3:
uses crt;
const fi='teptong.txt'
var a,b:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
readln(a,b);
writeln(a+b);
writeln(f1,a+b);
close(f1);
readln;
end.
cho tệp DataIn.txt chứa liên tiếp các số nguyên dương và âm, các số trên cùng một dòng ngăn cách nhau bởi dấu cách. viết chương trình đọc các số vào chương trình pascal và tính tổng rồi ghi ra DataOut.txt
xin giúp đỡ ạ
const fi='dulieu.txt'
fo='ketqua.txt'
var i,t:integer;
f1,f2:text;
a:array[1..9]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
t:=0;
for i:=1 to 9 do
begin
read(f1,a[i]);
t:=t+a[i];
end;
writeln(f2,t);
close(f1);
close(f2);
end.
const fi='dataln.txt'
fo='dataout.txt'
var f1,f2:text;
x,i,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
t:=0;
for i:=1 to 24 do
begin
read(f1,x);
t:=t+x;
end;
writeln(f2,t);
close(f1);
close(f2);
end.