Những câu hỏi liên quan
Ka Ka
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 3 2021 lúc 21:41

const fi='mang.txt'

fo='tong.txt'

var f1,f2:text;

a:array[1..100]of integer;

n,i,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewriteln(f2);

n:=0;

while not eof(f1) do 

  begin

inc(n);

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
Lan Ngọc
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 1 2022 lúc 23:13

#include <bits/stdc++.h>

using namespace std;

long long a,b;

double tb;

int main()

{

freopen("dulieu.inp","r",stdin);

freopen("ketqua.out","w",stdout);

cin>>a>>b;

cout<<a<<" "<<b;

cout<<fixed<<setprecision(2)<<(a*1.0+b*1.0)/(2*1.0);

return 0;

}

Bình luận (0)
M Ạ C H N H A
Xem chi tiết
Lê Ngọc Ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 2 2021 lúc 21:41

*Viết chương trình ghi hai số 5 và 15 vào tệp so.txt:

const f='so.txt'

var f1:text;

begin

assign(f1,f); rewrite(f1);

writeln(f1,'5 15');

close(f1);

end.

*Viết chương trình tính tổng, hiệu, tích, thương của x,y và in kết quả ra màn hình:

uses crt;

const fi='so.txt'

var x,y:integer;

f1:text;

begin

clrscr;

assign(f1,fi); reset(f1);

readln(f1,x,y);

writeln('Tong la: ',x+y);

writeln('Hieu la: ',x-y);

writeln('Tich la: ',x*y);

writeln('Thuong la: ',x/y:4:2);

close(f1);

readln;

end.

Bình luận (1)
Huyền Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2022 lúc 20:37

#include <bits/stdc++.h>

using namespace std;

long long x,y;

int main()

{

cin>>x>>y;

freopen("kq.txt","w",stdout);

cout<<x+y<<endl;

cout<<x-y<<endl;

cout<<x*y<<endl;

cout<<fixed<<setprecision(2)<<(x*1.0)/(y*1.0);

return 0;

}

Bình luận (0)
Nguyễn Đức Anh Khoa
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 1 2021 lúc 12:30

const fi='tong.inp'

fo='tong.out'

var f1,f2:text;

a:array[1..100]of integer;

n,i,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
A3-37-Bùi Ngọc Phương Tr...
Xem chi tiết
Nguyễn Thị In
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:04

const fi='dulieu.txt'

fo='ketqua.txt'

var f1,f2:text;

a,b:array[1..100]of integer;

n,i:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do

begin

n:=n+1;

readln(f1,a[n],b[n]);

end;

for i:=1 to n do 

begin

if (a[i]<b[i]) then writeln(f2,a[i])

else writeln(f2,b[i]);

end;

close(f1);

close(f2);

end.

Bình luận (0)
Mei Mei
Xem chi tiết