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.
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.
uses crt;
var a:array[1..100]of integer;
i,n,dem,max,t,min,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=-32000;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem:=dem+1;
if max<a[i] then max:=a[i];
end;
if dem=0 then writeln('Trong day khong co so chan')
else begin
writeln('So so chan la: ',dem);
writeln('So chan lon nhat la: ',max);
end;
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+a[i];
writeln('Tong cac so o vi tri le la: ',t);
min:=maxint;
dem1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
if min>a[i] then min:=a[i];
end;
if dem1=0 then writeln('Trong day khong co so le')
else writeln('So le nho nhat la: ',min);
readln;
end.
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;
for i:=1 to n do
if a[i] mod 6=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 3 va 6 la: ',t);
for i:=1 to n do
if a[i]>3 then write(a[i]:4);
writeln;
for i:=1 to n do
write(a[i]:4);
dem:=0;
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i] mod 5=0) then inc(dem);
writeln(dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 10=0 then
begin
write(a[i]:4);
inc(dem);
t:=t+a[i];
end;
writeln;
writeln(dem);
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n; cin >> n; //Nhập n;
ll a[n+5]; //Tạo mảng
vector<ll> v; //Tạo vector lưu vị trí của x (Có thể dùng mảng để lưu nhưng phải tạo thêm biến j để tăng chỉ số mỗi lần tìm được)
for(ll i=1;i<=n;i++) cin >> a[i]; //Nhập phần tử mảng
ll x, dem=0; //tạo x và biến đếm phần tử = x
cin >> x; //Nhập phần tử x;
for(ll i=1;i<=n;i++) {
if(a[i]==x) dem++, v.push_back(i); //lưu vị trí i vào vector
}
if(dem==0) cout << "0"; //nếu đếm bằng 0 thì k cần in ra chỉ số
else {
cout << dem << "\n"; //in ra đếm
for(auto it:v) cout << it << " "; //in ra chỉ số của phần tử bằng x
}
}
(Bạn có thể dùng thư viện iostream thay cho bits/stdc++.h và thay ll thành int cũng được nhé)
Chúc bạn học tốt!
program DemSoChanLeTrongMang;
var
A: array of Integer;
n, i, demChan, demLe: Integer;
begin
Write('Nhap so phan tu cua mang: ');
Readln(n);
SetLength(A, n);
for i:= 0 to n-1 do
begin
Write('A[', i, ']= ');
Readln(A[i]);
end;
demChan := 0;
demLe := 0;
for i:= 0 to n-1 do
begin
if A[i] mod 2 = 0 then
demChan := demChan + 1
else
demLe := demLe + 1;
end;
Writeln('So luong so chan trong mang la: ', demChan);
Writeln('So luong so le trong mang la: ', demLe);
end.
Var a:array[1..200] of integer;
i,n,dem:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
dem:=0;
For i:=1 to n do
If a[i]>5 then dem:=dem+1;
Write('So phan tu lon hon 5 la ',dem);
Readln;
End.
var a:array[1..1000] of integer;
i,n,d:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('nhap so thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then d:=d+1;
end;
write('Cac so o vi tri le la ');
for i:=1 to n do
if i mod 2 <> 0 then write(a[i]:8);
writeln;
write('co ',d,' so le');
readln
end.