Những câu hỏi liên quan
Lê Đức Tài
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 14:06

#include <bits/stdc++.h>

using namespace std;

long long i,a[100],n;

int main()

{

freopen("songuyen.txt","r",stdin);

n=20;

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

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Trang Ha
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 2 2021 lúc 19:30

const fi='songuyen.txt'

fo='kluan.txt'

var f1,f2:text;

n:integer;

begin

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

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

readln(f1,n);

if n mod 2=0 then writeln(f2,'La so chan')

else writeln(f2,'La so le');

close(f1);

close(f2);

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: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)
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)
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)
Phương Hoài
Xem chi tiết
Quyên Mai
17 tháng 3 2023 lúc 21:19

mình cũng cần ạ

Bình luận (0)
Minh Lệ
17 tháng 3 2023 lúc 23:04

a)

Input: Số nguyên dương N, dãy số a1,a2,a3,...,an

Output: Tổng các số chẵn nhỏ hơn hoặc bằng N

b)

Program HOC24;

var i,n: integer;

t: longint;

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

f1,f2: text;

const fi='SONGUYEN.TXT'

fo='SOCHAN.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]);

for i:=1 to n do if (a[i] mod 2=0) and (a[i]<=n) then

begin

write(f2,a[i],' ');

t:=t+a[i];

end;

writeln(f2);

write(f2,t);

close(f1); close(f2);

end.

Bình luận (0)
Thanh Vjp pro
Xem chi tiết
Giang Vũ
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2021 lúc 21:24

uses crt;

const fi='dulieu.txt'

var f1:text;

a,b,c,d:integer;

begin

clrscr;

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

readln(f1,a,b,c,d);

writeln(a*b*c*d);

close(f1);

readln;

end.

Bình luận (0)