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.
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;
}
uses crt;
var a,b,c:array[1..250]of integer; i,n,dem,dem1,sd,vtd,sa,vta,sdcc,sacc,vtd1,vtc1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
if a[i]<0 then
begin
inc(dem1);
c[dem1]:=a[i];
end;
end;
writeln('So duong dau tien trong day la: ',b[1]);
sd:=b[1];
vtd:=n;
for i:=n downto 1 do
if sd=a[i] then
begin
if vtd>i then vtd:=i;
end;
writeln('Chi so cua no la: ',vtd);
writeln('So am dau tien trong day la: ',c[1]);
sa:=c[1];
vta:=n;
for i:=n downto 1 do
if sa=a[i] then
begin
if vta>i then vta:=i;
end;
writeln('Chi so cua no la: ',vta);
writeln('So duong cuoi cung trong day la: ',b[dem]); sdcc:=b[dem];
vtd1:=1;
for i:=1 to n do
if sdcc=a[i] then
begin
if vtd1<i then vtd1:=i;
end;
writeln('Chi so cua no la: ',vtd1);
writeln('So am cuoi cung trong day la: ',c[dem]); sacc:=c[dem];
vtc1:=1;
for i:=1 to n do
if sacc=a[i] then
begin
if vtc1<i then vtc1:=i;
end;
writeln('Chi so cua no la: ',vtc1);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,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.
Program bt_3;
Uses crt;
Var a: array[1..100] of integer;
Dem, Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap so phan tu, n=’);
Readln (n);
for i := 1 to n do
begin
writeln(‘nhap gia trij phan tu thu ’,i,’ =’);
readln(a[i]);
end;
Dem:=0;
Tong:=0;
For i:=1 to n do
If (a[i] mod 2 = 1) and (a[i] mod 3 = 0) then
begin
Dem:= Dem+1;
Tong:= Tong+a[i];
end;
writeln(‘Dem la:’,Dem);
Writeln(‘Tong la:’,Tong);
Readln
End.
Program bt_3;
Uses crt;
Var a: array[1..100] of integer;
Dem, Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap so phan tu, n=’);
Readln (n);
for i := 1 to n do
begin
writeln(‘nhap gia trij phan tu thu ’,i,’ =’);
readln(a[i]);
end;
Dem:=0;
Tong:=0;
For i:=1 to n do
If (a[i] mod 2 = 1) and (a[i] mod 5 = 0) then
begin
Dem:= Dem+1;
Tong:= Tong+a[i];
end;
writeln(‘Dem la:’,Dem);
Writeln(‘Tong la:’,Tong);
Readln
End.
tham khảo
#include <bits/stdc++.h>
using namespace std;
long long n,i,nn,t1,t2,dem1,dem2,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn<<endl;
for (i=1; i<=n;i++)
if (a[i]%2==0) cout<<a[i]<<" ";
cout<<endl;
for (i=1; i<=n;i++)
if (a[i]%2!=0) cout<<a[i]<<" ";
cout<<endl;
t1=0;
t2=0;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
if (a[i]%2==0)
{
t1+=a[i];
dem1++;
}
else
{
t2+=a[i];
dem2++;
}
}
cout<<t1<<" "<<dem1<<endl;
cout<<t2<<" "<<dem2;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,min,t1,t2,dem1,dem2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
min:=a[1];
for i:=1 to n do if min>a[i] then min:=a[i];
writeln(min);
writeln('Cac so chan la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
writeln;
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
writeln(t1,' ',t2);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then dem1:=dem1+1
else dem2:=dem2+1;
end;
writeln(dem1,' ',dem2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2!=0) dem++;
}
cout<<dem;
return 0;
}