K
Khách

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[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;

}

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 x,n,i,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x>0) t+=x;

}

cout<<t;

return 0;

}

9 tháng 3 2021

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..50]of integer;

i,n:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

for i:=1 to n do write(a[i]:4);

readln;

end.

uses crt;

var a:array[1..50]of integer;

i,n:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

readln;

end.

uses crt;

var a:array[1..1000]of integer;

i,n,dem,t:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (0<n) and (n<=1000);

for i:=1 to n do 

begin

repeat

write('A[',i,']='); readln(a[i]);

until abs(a[i])<=1000;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do 

  if a[i]=0 then inc(dem);

writeln('So phan tu bang 0 la: ',dem);

t:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then t:=t+a[i];

writeln('Tong cac phan tu chan la: ',t);

readln;

end.