Những câu hỏi liên quan
Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

Bài 1:

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if ((x<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
Nguyễn Đức Ánh
Xem chi tiết
quân nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 21:42

a: 

#include <bits/stdc++.h>

using namespace std;

double a[1000];

int n,i;

int main()

{

cin>>n;

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

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

return 0;

}

b: 

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

t=0;

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

cout<<t;

return 0;

}

Bình luận (1)
nguyễn hoàng long
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 22:00

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

int main()

{

cin>>n;

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

{

cin>>a[i];

}

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

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]%3==0) dem++;

cout<<dem<<" ";

t1=0;

dem1=0;

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

if (a[i]%2!=0)

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

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

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

return 0;

}

Bình luận (0)
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)
Benny
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 3 2023 lúc 14:55

6:

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,A[100],i,dem=0;

cin>>n;

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

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

if (A[i]%2!=0) dem++;

cout<<dem;

return 0;

}

5:

#include <bits/stdc++.h>

using namespace std;

int main()

{

long long n,nn=1e6,A[1000];

cin>>n;

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

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

nn=min(nn,A[i]);

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

if (nn==A[i]) cout<<i<<" ";

return 0;

}

Bình luận (0)
ngomanhcuong
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

Bình luận (0)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:09

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

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

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)
zero
20 tháng 1 2022 lúc 14:08

B

Bình luận (1)
Chanh Xanh
20 tháng 1 2022 lúc 14:08
Bình luận (1)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:08

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

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

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)