Những câu hỏi liên quan
Trần Vi Sa
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:50

uses crt;

const fi='tep.txt'

var f1:text;

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

i,n,kt,j,dem:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

readln(f1,a[n]);

end;

dem:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then inc(dem);

end;

writeln(dem);

close(f1);

readln;

end.

Bình luận (0)
Nguyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 4 2021 lúc 22:38

1:

const fi='Dulieu.txt'

fo='ketqua.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

inc(n);

read(f1,a[n]);

end;

for i:=1 to n do 

  if (a[i]>0) and (a[i] mod 2=0) then write(f2,a[i]:4);

close(f1);

close(f2);

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
1 tháng 4 2021 lúc 22:40

P/s: Cái này mình viết chương trình chính thôi nhé, còn hàm và thủ tục bạn tự viết nhé(chỉ cần lấy ý tưởng trong chương trình chính ra viết là được rồi)

2:

uses crt;

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

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

 begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i]>=0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (1)
Đặng Công
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:31

uses crt;

const fi='dl.txt'

fo='soam.txt'

var f1,f2:text;

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

i,n:integer;

begin

clrscr;

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

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

n:=0;

while not eoln(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

for i:=1 to n do 

begin

  if a[i]>0 then writeln('Can bac hai cua ',a[i],' la: ',sqrt(a[i]):4:2)

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

end;

close(f1);

close(f2);

readln;

end.

Bình luận (0)
Đặng Công
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:32

uses crt;

const fi='dl.txt'

fo='soam.txt'

var f1,f2:text;

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

i,n:integer;

begin

clrscr;

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

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

n:=0;

while not eoln(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

for i:=1 to n do 

begin

  if a[i]>0 then writeln('Can bac hai cua ',a[i],' la: ',sqrt(a[i]):4:2)

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

end;

close(f1);

close(f2);

readln;

end.

Bình luận (0)
An Đinh
Xem chi tiết
Minh Lệ
19 tháng 3 2023 lúc 22:52

Program HOC24;

var i,n: integer;

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

t: longint;

f1,f2: text;

const fi='DATA1.TXT'

fo='KQ1.TXT'

begin

assign(f1,fi);

assign(f2,fo);

reset(f1);

rewrite(f2);

readln(f1,n);

for i:=1 to n do read(f1,a[i]);

t:=0;

for i:=1 to n do if a[i] mod 2=0 then t:=t+a[i];

writeln(f2,t);

for i:=1 to n do if a[i] mod 5=0 then write(f2,a[i],' ');

close(f1); close(f2);

end.

Bình luận (0)
nanako
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:22

uses crt;

const fi='bt.txt'

fo='soam.txt'

var f1,f2:text;

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

i,n:integer;

begin

clrscr;

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

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

n:=0;

while not eoln(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

for i:=1 to n do 

begin

  if a[i]>0 then writeln('Can bac hai cua ',a[i],' la: ',sqrt(a[i]):4:2)

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

end;

close(f1);

close(f2);

readln;

end.

Bình luận (0)
Phạm Tiến Vượng
Xem chi tiết
Phan Tú
Xem chi tiết
duc tran
Xem chi tiết