Những câu hỏi liên quan
nguyễn hoàng
Xem chi tiết
Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 12 2020 lúc 22:20

uses crt;

var g:array[1..5]of integer;

i,vtc,vtl:integer;

begin

clrscr;

for i:=1 to 5 do 

  begin

write('G[',i,']='); readln(g[i]);

end;

vtc:=0;

vtl:=0;

for i:=1 to 5 do 

  begin

if g[i] mod 2=0 then 

  begin

  if vtc<i then vtc:=i;

end

else begin

if vtl<i then vtl:=i;

end;

end;

writeln('Vi tri phan tu le cuoi cung la: ',vtl);

writeln('Vi tri phan tu chan cuoi cung la: ',vtc);

readln;

end. 

Bình luận (0)
Mỹ Phượng
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 1 2022 lúc 11:29

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,t,dem;

int main()

{

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

t=0;

dem=0;

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

{

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

else dem++;

}

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

cout<<endl;

cout<<t<<endl;

cout<<dem;

return 0;

}

Bình luận (1)
Boa Hancock
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 1 2022 lúc 22:33

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

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

else dem1+=1;

if ((a[i]%2==0) or (a[i]%3==0)) s=s*a[i];

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

Bình luận (0)
Boa Hancock
Xem chi tiết
Boa Hancock
12 tháng 1 2022 lúc 7:58

Viết câu lệnh thực hiện yêu cầu sau:

4. Với dữ liệu câu 2, yêu cầu tính và in ra màn hình:

4a. Tổng các số chẵn

4b. Đếm các số lẽ

4c. Tích các số chia hết cho 2 hoặc 3

 

Bình luận (0)
Nguyễn Lê Phước Thịnh
12 tháng 1 2022 lúc 22:33

#include <bits/stdc++.h>

using namespace std;

long long a[10],i,n,t1,dem1,s;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

dem1=0;

s=1;

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

{

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

else dem1+=1;

if ((a[i]%2==0) or (a[i]%3==0)) s=s*a[i];

}

cout<<t1<<endl;

cout<<dem1<<endl;

cout<<s;

return 0;

}

 

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

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,t1,t2,t3;

int main()

{

cin>>n;

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

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

cout<<endl;

t1=0;

t2=0;

t3=0;

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

{

t1+=a[i];

if (a[i]<0) t2+=a[i];

if (a[i]>0) t3+=a[i];

}

cout<<t1<<endl;

cout<<t2<<endl;

cout<<t3;

return 0;

}

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

uses crt;

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

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

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

writeln(t);

readln;

end.

Bình luận (0)
Võ Trần Nguyên
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:44

uses crt;

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

i,n,t,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then

begin

t:=t+a[i];

inc(dem);

end;

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

writeln('So luong so chan la: ',dem);

readln;

end.

Bình luận (0)