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 a:array[1..100]of integer;
n,k,t,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(n);
end;
for i:=n downto 1 do
write(a[i]:4);
writeln;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if k mod a[i]=0 then t:=t+a[i];
writeln(t);
for i:=1 to n do
if a[i]=k then write(i:4);
readln;
end.
uses crt;
var a:array[1..200]of integer;
n,i,k,t,t1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
readln;
end.
program so_lon_nhat;
uses crt;
var a: array[1..100] of integer;
i,n,max,k,dem: integer;
s,tbc: real;
begin
clrscr;
writeln(' nhap so phan tu cua day'); readln(n);
for i:=1 to n do
begin
writeln('a[',i,']'); readln(a[i]);
end;
writeln(' nhap so can tim:'); readln(k);
max:=a[1];
i:=1;
dem:=0;
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
s:=s+a[i];
tbc:=s/n;
if a[i]=k then dem:=dem+1;
end;
writeln(' so lon nhat trong day tren la:',max);
while (i<n) and (a[i]<>k) do i:=i+1;
if a[i]=k then writeln(' phan tu thu ', i ,' bang ',k)
else writeln(' k tim dc phan tu',k);
writeln(tbc:6);
writeln('co', dem, ' phan tu', k);
readln
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,t,dem,x;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
if (x%2==0) dem++;
}
cout<<t<<endl;
cout<<dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t,min,vt: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 then t:=t+a[i];
writeln('Tong cac so chia het cho 3 la: ',t);
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
vt:=1;
for i:=1 to n do
if min=a[i] then
begin
if vt<i then vt:=i;
end;
writeln('Gia tri nho nhat la: ',min);
writeln('Vi tri la: ',vt);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,j,tam:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:5);
writeln;
writeln('Cac so duong la: ');
for i:=1 to n do if (a[i]>0) then write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln(t);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,t,k,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=LLONG_MIN;
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<"So lon nhat la: "<<ln<<endl;
cout<<"VI tri la: ";
for (i=1; i<=n; i++) if (ln==a[i]) cout<<i<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (a[i]>0) t+=a[i];
cout<<"Tong cac so duong la: "<<t<<endl;
cin>>k;
for (i=1; i<=n; i++)
if (a[i]%k==0) cout<<a[i]<<" ";
cout<<endl;
nn=LLONG_MAX;
for (i=1; i<=n; i++)
nn=min(nn,a[i]);
cout<<nn;
return 0;
}