Những câu hỏi liên quan
Phan Hùng Anh
Xem chi tiết
Minh Lệ
2 tháng 5 2023 lúc 20:48

Program HOC24;

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

i,n: byte;

t: longint;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

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

end;

write('Cac phan tu chan trong mang la: ');

for i:=1 to n do

if a[i] mod 2=0 then

begin

write(a[i],' ');

t:=t+a[i];

end;

writeln;

write('Tong cac phan tu chan trong day la: ',t);

readln

end.

Bình luận (0)
Phạm Gia Bình
Xem chi tiết
Anh Phạm
17 tháng 8 2021 lúc 9:54

uses crt;

var n,i,chan,tonchan:integer;

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

begin

write('nhap n '); readln(n);

for i:=1 to n do

begin

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

end;

writeln("in cac phan tu trong mang");

for i:=1 to n do

begin

writeln(a[i]);

end;

writeln("in cac phan tu chan");

chan:=0;

for i:=1 to n do

if n mod 2=0 then begin writeln(a[i]); chan:=chan+1; end;

write('tong cac phan tu chan ',chan);

readln;

end.

 

Bình luận (3)
Minh Duy
Xem chi tiết
Bùi Anh Tuấn
27 tháng 4 2021 lúc 19:53

 tách ra từng câu hỏi đi bro

Bình luận (0)
Nguyễn Lê Phước Thịnh
27 tháng 4 2021 lúc 21:35

Câu 1: 

uses crt;

var a:array[1..200]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(t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
27 tháng 4 2021 lúc 21:35

2:

uses crt;

var a:array[1..200]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:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t);

readln;

end.

Bình luận (0)
Trần Cương
Xem chi tiết
Ngô Thành Chung
22 tháng 3 2022 lúc 22:07

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

      i,n,S,d:byte;

 begin

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

  for i:=1 to n do begin

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

                           readln(A[i]);

                          end;

d:=0; S:=0;

for i:=1 to n do if A[i] mod 2 = 0 then begin

                                                          d:=d+1;

                                                           S:=S+A[i];

                                                           end;

write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);

readln

end.

                                                          

                      

  

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)
vutransosn
Xem chi tiết
Vochehoang
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 4 2021 lúc 20:04

Câu 1: 

uses crt;

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

i,n:integer;

t:real;

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(t:4:2);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
26 tháng 4 2021 lúc 20:05

Câu 2: 

uses crt;

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

i,n:integer;

t:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=1;

for i:=1 to n do 

  t:=t*a[i];

writeln(t:4:2);

readln;

end.

Bình luận (0)
Hương Lê
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:50

Bài 1

Var a:array:[1..99] of integer;

i,n:integer;

s:longint;

Begin

Repeat

Write('n = ');readln(n);

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

Write('Nhap diem thu ',i,' = ');readln(a[i]);

if a[i] mod 2 = 0 then s:=s+a[i];

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so chan la ',s);

Readln

End.

Bình luận (0)
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:50

Bài 2

Var a:array:[1..99] of integer;

i,n:integer;

s:longint;

Begin

Repeat

Write('n = ');readln(n);

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

Write('Nhap diem thu ',i,' = ');readln(a[i]);

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

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so le la ',s);

Readln

End.

Bình luận (0)
Phạm Gia Bình
Xem chi tiết
Minh Lệ
24 tháng 8 2021 lúc 21:12

Program HOC24;

var d,i,n: integer;

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

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin 

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

end;

write('Cac phan tu cua mang vua nhap la: ');

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

writeln;

d:=0;

for i:=1 to n do if 10 mod a[i]=0 then d:=d+1;

writeln('Co ',d,' phan tu co gia tri la uoc cua 10');

write('Cac phan tu o vi tri chan la: ');

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

writeln;

write('Cac phan tu o vi tri le la: ');

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

readln

end.

Bình luận (0)