*Cách 1:Thông thường.
program nguyento;
uses crt;
var A:array[1..1000] of inteegr;
n,i,d:integer;
begin
clrscr;
write('Nhap so luong phan tu n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
end;
write('Cac so nguyen to trong mang la: ');
for i:=1 to n do
if A[i]>2 then
begin
d:=0;
for j:=2 to n div 2 do
if n mod j=0 then
begin
d:=1;
break;
end;
if d=0 then write(A[i],' ');
end;
readln;
end.
*Cách 2:Nâng cao.
program nguyento;
uses crt;
var A:array[1..1000] of integer;
n,i,d:integer;
function ktnt(k:integer):boolean;
var l:integer;
begin
ktnt:=false;
if k<2 then exit;
for l:=2 to trunc(sqrt(k)) do
if k mod l=0 then exit;
ktnt:=true;
end;
BEGIN
clrscr;
write('Nhap so luong phan tu n: '); readln(n);
d:=0;
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
if ktnt(A[i]) then d:=d+1;
end;
if d=0 then write('Khong co so nguyen to trong day')
else
begin
write('Co ',d,' so nguyen to trong day do la: ');
for i:=1 to n do
if ktnt(A[i]) then write(A[i],' ');
end;
readln;
end.
program Project1;
uses crt;
var
a:array[1..100] of integer;
n, i:integer;
begin
clrscr;
write('Nhap vao so phan tu co trong day:='); readln(n);
for i:=1 to n do
begin
write('Nhap vao phan tu thu ',i,' :='); readln(A[i]);
end;
for i:=1 to n do
writeln(A[i]);
rea
program nguyento;
uses crt;
var A:array[1..1000] of integer;
n,i,d:integer;
function ktnt(k:integer):boolean;
var l:integer;
begin
ktnt:=false;
if k<2 then exit;
for l:=2 to trunc(sqrt(k)) do
if k mod l=0 then exit;
ktnt:=true;
end;
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 8 - Năm thứ ba ở cấp trung học cơ sở, học tập bắt đầu nặng dần, sang năm lại là năm cuối cấp áp lực lớn dần nhưng các em vẫn phải chú ý sức khỏe nhé!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK