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.

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

2 tháng 3 2021

viết rõ hộ câu hỏ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;

}

19 tháng 3 2021

ai đó giúp mình gấp vớ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;

i,n,k: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);

for i:=1 to n do 

  if a[i] mod k=0 then write(a[i]:4);

readln;

end.

23 tháng 3 2023

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do 

begin

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

end;

d:=0;

for i:=1 to n do if a[i] mod 3=0 then d:=d+1;

write('Co ',d,' so chia het cho 3');

readln

end.

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.

31 tháng 1 2021

Sao em chạy đáp án nó ra sai ví dụ em nhập số 2 thì nó là số nguyên tố mà trong máy tính thì nói không có số nguyên tố