Những câu hỏi liên quan
Lê Thị Hồng Trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 3 2022 lúc 22:46

uses crt;

const fi='so.inp'

var f1:text;

a,b:integer;

begin

clrscr;

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

while not eof(f1) do 

 begin

readln(f1,a,b);

writeln((a+b)/2:4:2);

end;

close(f1);

readln;

end.

Bình luận (0)
Nguyễn Gia Bảo
Xem chi tiết
Nguyễn Văn Thường
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2022 lúc 18:51

const fi='input.txt'

fo='soan.txt'

var f1,f2:text;

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

i,n: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]);

end;

for i:=1 to n do 

  if a[i]<0 then writeln(f2,a[i]:4);

close(f1);

close(f2);

end.

Bình luận (0)
Ngọc Ánh
Xem chi tiết
Nguyen Hung
3 tháng 5 2021 lúc 21:04

Uses crt;

Var i,n,tong:integer;

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

      f1,f2:text;

Begin

clrscr;

Assign(f1,'tinhtong.inp');

Assign(f2,'tinhtong.out');

tong:=0;

Reset(f1);readln(f1,n);

For i:= 1 to n do

Begin

read(f1,a[i]);

tong:=tong+a[i];

End;

close(f1);

rewrite(f2);

Writeln(f2,tong);

Readln;

End.

Bình luận (1)
Nguyễn Nhật Bình
Xem chi tiết
Kiên Tạ
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 20:46

const fi='dulieu.txt'     

fo='ketqua.txt'

var f1,f2:text;   

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

i,n,dem,dem1: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;

dem:=0;

dem1:=0;

for i:=1 to n do 

if a[i]>b[i] then     

begin       

inc(dem);       

inc(dem1);       

c[dem]:=a[i];       

d[dem]:=b[i];     

end 

else begin         

inc(dem);         

inc(dem1);         

c[dem]:=b[i];         

d[dem]:=a[i];       

end;

for i:=1 to dem do 

write(f2,c[i]:4);

writeln(f2);

for i:=1 to dem1 do 

write(f2,d[i]:4);

close(f1);

close(f2);

end.

Bình luận (0)
NGUYỄN THỊ MỸ LINH
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 1 2022 lúc 21:40

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

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

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

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

if (a[i]%2==0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Ngô Chí Thành
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:59

const fi1='nguyen1.txt'

fi2='nguyen2.txt'

fo='nguyen.txt'

var f1,f2,f3:text;

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

n,m,i:integer;

begin

assign(f1,fi1); reset(f1);

assign(f2,fi2); reset(f2);

assign(f3,fo); rewrite(f3);

n:=0;

while not eof(f1) do 

  begin

inc(n);

readln(f1,a[n]);

end;

m:=0;

while not eof(f2) do 

begin

m:=m+1;

readln(f1,b[m]);

end;

for i:=1 to n do 

 writeln(f3,a[i]);

for i:=1 to m do 

  writeln(f3,b[i]);

close(f1);

close(f2);

close(f3);

end.

Bình luận (0)
Louis Kai
Xem chi tiết
Mộng Chúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 10:03

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,j;

bool kt;

int main()

{

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

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

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

if (a[i]>1) 

{

kt=true;

for (j=2; j*j<=a[i]; j++)

if (a[i]%j==0) kt=false;

if (kt==true) cout<<a[i]<<" ";

}

return 0;

}

Bình luận (0)