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.
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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
#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;
}
Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
edn;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
#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;
}
#include <bits/stdc++.h>
using namespace std;
long long x,i,n=4,dem;
int main()
{
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem++;
}
cout<<dem;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
ln=a[1];
nn=a[1];
for (i=2; i<=n; i++)
{
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<ln<<" "<<nn;
}
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
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.