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 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;
}
uses crt;
var a:array[1..100]of integer;
i,n,kt,dem,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then
begin
kt:=1;
break;
end;
if kt=0 then inc(dem);
end;
writeln('So phan tu la so nguyen to la: ',dem);
readln;
end.
Bạn tham khảo link :https://hoc247.net/hoi-dap/tin-hoc-11/viet-chuong-trinh-lap-mang-a-gom-n-so-nguyen-faq299502.html
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;
i,n,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<=n) and (n<=1000);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then inc(dem);
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t;
return 0;
}