Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
#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;
}
uses crt;
var a:array[1..100]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]<0) and (i mod 2=1) then t:=t+a[i];
writeln('Tong cac phan tu am tai vi tri le la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[40],i,n,ln;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
for (i=n; i>=1; i--)
if (ln==a[i])
{
cout<<i;
break;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[6],i,t,t1;
int main()
{
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]%2==0) t=t+a[i];
}
t1=0;
for (i=1; i<=n; i++)
if ((a[i]%2!=0) and (i%2==0)) t1=t1+a[i];
cout<<t<<endl;
cout<<t1;
return 0;
}
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.
uses crt;
var a:array[1..100]of integer;
n,dem,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if i mod 2=1 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('Trung binh cong cac phan tu o vi tri le la: ',t/dem:4:2);
readln;
end.
uses crt;
var a:array[1..100]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 3=0) and (i mod 2=0) then t:=t+a[i];
writeln('Tong cac so chia het cho 3 o vi tri chan la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int B[100],i,n,t=0,s=1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>B[i];
for (int i=1; i<=n; i++)
{
if (i%2==0) s*=A[i];
else t+=A[i];
}
cout<<t<<" "<<s;
}