0
0
Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
2377
1794
uses crt;
var i,n,vt,dnt,s,x,lp,j,t:longint; a:array[1..1000000]of longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
begin
clrscr;
write('Nhap N (N<=50): ');readln(n);
write('Nhap X: ');readln(x);
for i:=1 to n do
begin
write('A[',i,']= ');readln(a[i]);
inc(s,a[i]);
if x=a[i] then vt:=i;
if a[i] mod 2=0 then lp:=lp*a[i]*a[i]*a[i];
if nt(a[i]) then inc(dnt);
for j:=1 to i-1 do
if a[i]>a[j] then
begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end;
end;
writeln('a) Tong: ',s);
if dnt=0 then writeln('b) X khong co trong mang') else
writeln('b) Vi tri cua x: ',vt);
writeln('c) Tich lap phuong cua ca phan tu chan: ',lp);
writeln('d) Mang da sap xep: ');
for i:=1 to n do write(a[i],' '); writeln;
writeln('e) Mang co ',dnt,' so nguyen to');
readln
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
2863
21138
program bai_giai;
uses crt;
var A:array[1..10000] of integer;
n,i,t,d,x,dnt,tlt,tg,j:longint;
{---HAM-NT---}
function ktnt(k:longint):boolean;
var r:longint;
begin
ktnt:=false;
if k<2 then exit;
for r:=2 to trunc(sqrt(k)) do
if k mod r=0 then exit;
ktnt:=true;
end;
{---CT-chinh---}
BEGIN
clrscr;
repeat
write('Nhap N = '); readln(n);
if (n<1) or (n>50) then writeln('Nhap lai!');
until (n>0) and (n<=50);
t:=0; tlt:=1; dnt:=0;
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
t:=t+A[i];
if A[i] mod 2=0 then tlt:=tlt*A[i]*A[i]*A[i];
if ktnt(A[i]) then dnt:=dnt+1;
end;
writeln('a) Tong cac phan tu trong mang la: ',t);
write('b) Nhap X: '); readln(x);
d:=0;
for i:=1 to n do
if A[i]=X then
begin
write(i,' ');
d:=d+1;
end;
if d=0 then write('Khong co');
writeln;
writeln('c) Tich lap phuong cac phan tu chan la: ',tlt);
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]<A[j] then
begin
tg:=A[i];
A[i]:=A[j];
A[j]:=tg;
end;
write('d) Mang giam dan: ');
for i:=1 to n do write(A[i],' ');
writeln;
writeln('e) Co ',dnt,' so nguyen to');
readln;
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
463
608
bạn ơiiii
2863
21138
sao
463
608
vào vote cho mk vs Mk sắp lên siêu sao r
463
608
cám ơn nhìu ạ
Bảng tin
463
13536
608
bạn ơiii
463
13536
608
vào vote cho mk vs Mk sắp lên siêu sao r