Những câu hỏi liên quan
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)
09 Lê Quang HIếu
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 21:34

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if (x<0) t+=x;

}

cout<<t;

return 0;

}

Bình luận (0)
trần nguyễn tuyết trinh
Xem chi tiết
Minh Lệ
9 tháng 4 2023 lúc 18:34

Program HOC24;

var i,n: integer;

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

f: text;

begin

assign(f,'MANG3.TXT');

reset(f);

readln(f,n);

for i:=1 to n do read(f,c[i]);

close(f);

for i:=1 to n do if c[i] mod 2=1 then write(c[i],' ');

readln

end.

Bình luận (0)
trần nguyễn tuyết trinh
9 tháng 4 2023 lúc 11:39

cứu e với mn

 

Bình luận (0)
trần nguyễn tuyết trinh
Xem chi tiết
Mạnh Cường Đào Huỳnh
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 23:55

const fi='input.txt'

fo='output.txt'

var f1,f2:text;

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

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

t:=0;

for i:=1 to n do t:=t+a[i];

write(f2,t);

close(f1);

close(f2);

end.

Bình luận (0)
Thanh Vjp pro
Xem chi tiết
Divine 000
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2021 lúc 13:50

Câu 1: 

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 

  t:=t+a[i];

writeln('Tong cac so trong mang la: ',t);

readln;

end.

Câu 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] mod 2=0 then t:=t+a[i];

writeln('Tong cac so chan la: ',t);

readln;

end.

Bình luận (0)
Tran Ngô
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 13:39

const fi='data.txt'

fo='tbc.txt'

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);

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

readln(f1,a[n]);

end;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t/n:4:2);

close(f1);

close(f2);

end.

Bình luận (1)
Trần Trọng Hùng
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 3 2022 lúc 11:20

#include <bits/stdc++.h>
using namespace std;
unsigned long long a[1000],i,n,uc;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
    if (b==0) return(a);
    else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
    freopen("sn3.inp","r",stdin);
    freopen("uc.out","w",stdout);
    cin>>n;

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

uc=ucln(a[1],a[2]);

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

uc=ucln(uc,a[i]);

cout<<uc;
    return 0;
}

 

Bình luận (1)