Những câu hỏi liên quan
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)
nông thị ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:41

uses crt;

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

n,i,k,t,t1:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

t:=0;

for i:=1 to n do 

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

t1:=0;

for i:=1 to n do 

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

writeln('Tong cac phan tu le la: ',t);

writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);

readln;

end.

Bình luận (1)
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)
An Phạm
Xem chi tiết
Kiều Vũ Linh
28 tháng 4 2023 lúc 16:06

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

i,n,d,max:integer;

begin

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

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' = ');readln(a[i]);

if a[i] mod 2 <> 0 then d:=d+1;

end;

max:=a[1];

for i:=2 to n do

if a[i] > max then max:=a[i];

writeln('Co ',d,' so le');

write('So lon nhat la ',max);

readln

end.

Bình luận (0)
Trung Trần Việt
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 3 2022 lúc 19:00

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

n=5;

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++) t+=a[i];

cout<<t<<endl;

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

if (i%2!=0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Tống hiền chi
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 22:30

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem1,dem2;

int main()

{

cin>>n;

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

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

cout<<endl;

dem1=0;

dem2=0;

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

{

if (a[i]%2==0) dem1++;

else dem2++;

}

cout<<dem1<<" "<<dem2;

return 0;

}

Bình luận (0)
Xuân Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 3 2022 lúc 8:12

uses crt;

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

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

dem1:=0;

for i:=1 to n do 

  if (a[i]>a[i-1]) and (a[i]>a[i+1]) then dem1:=dem1+1;

dem2:=0;

for i:=1 to n do 

  if (a[i]<a[i-1]) and (a[i]<a[i+1]) then dem2:=dem2+1;

writeln(dem1);

writeln(dem2);

readln;

end.

Bình luận (0)
Thảo Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2021 lúc 10:41

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

t=0;

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

{

cin>>a[i];

t=t+a[i];

}

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

cout<<endl;

dem=0;

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

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

cout<<dem<<endl;

cout<<t;

return 0;

}

Bình luận (0)
my nguyễn
Xem chi tiết
Minh Lệ
23 tháng 3 2022 lúc 12:51

Program HOC24;

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

i: byte;

t: longint;

begin

for i:=1 to 10 do

begin

write('Nhap phan tu thu ',i,': '); readln(a[i]);

end;

t:=0;

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

wrie('Tong 10 phan tu do la: ',t);

readln

end.

Bình luận (0)