Những câu hỏi liên quan
Đặng Minh quân
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2021 lúc 18:41

uses crt;

const fi='dulieu.inp'

var f1:text;

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

n,i,t1,t2:integer;

begin

clrscr;

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

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t1:=0;

t2:=0;

for i:=1 to n do 

 begin

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

if a[i]<0 then t2:=t2+a[i];

end;

writeln('Tong cac so duong la: ',t1);

writeln('Tong cac so am la: ',t2);

close(f1);

readln;

end.

Bình luận (0)
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)
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 3 2022 lúc 22:48

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n,t;

int main()

{

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

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

cin>>n;

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

t=0;

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

cout<<fixed<<setprecision(1)<<(t*1.0)/(n*1.0);

return 0;

}

Bình luận (0)
thiên thanh
Xem chi tiết
Hello1234
Xem chi tiết
Hello1234
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 10 2021 lúc 0:25

#include <bits/stdc++.h>;
using namespace std;
int main()
{
    long i,n;
    float tbc,dem,t,a[10000];
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    dem=0;
    t=0;
    for (i=1; i<=n; i++)
        if (a[i]<0)
    {
        dem=dem+1;
        t=t+a[i];
    }
    tbc=t/dem;
    cout<<fixed<< setprecision(2)<<tbc;
    return 0;
}

 

Bình luận (0)
Hiếu Phùng
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:18

uses crt;

const fi='dayso.inp',

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

i,n:integer;

f1:text;

begin

clrscr;

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

readln(f1,n);

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

for i:=1 to n do write(a[i]:4);

close(f1);

readln;

end.

Bình luận (0)
APOK FF
Xem chi tiết
Huyền Trang
Xem chi tiết