bài 1:
function nto(n:longint):boolean;
var i : longint;
begin
if n < 2 then exit(false);
for i := 2 to trunc(sqrt(n)) do
if n mod i = 0 then exit(false);
exit(true);
end;
var a,b,c:array[0..10000007] of longint;
i,n,d,j:longint;
begin
write('Nhap vao so phan tu ');readln(n);
write('Nhap vao phan tu ');
for i := 1 to n do
begin
read(a[i]);
if nto(a[i]) then
begin
inc(d);
b[d]:=a[i];
end
else
begin
inc(j);
c[j]:=a[i];
end;
end;
write('a.',' So nguyen to trong day ');
for i := 1 to d do
write(b[i],' '); writeln;
write('Co ',d,' so nguyen to'); writeln;
write('b.',' So hoan chinh trong day ');
for i := 1 to j do
write(c[i],' ');
readln;readln;
end.
bài 2
var a,vt:array[0..100007] of longint;
i,n,ma,mi,x,d,j,c,l,tam:longint;
begin
write('Nhap vao so phan tu ');readln(n);
ma := -maxlongint;
mi := maxlongint;
write('Nhap vao phan tu ');
for i := 1 to n do
begin
read(a[i]);
if ma < a[i] then
begin
ma := a[i];
c := 1;
end
else if ma = a[i] then inc(c);
if mi > a[i] then mi := a[i];
end;
write('Nhap vao so x ');readln(x);
for i := 1 to n do
begin
if a[i] > x then
begin
inc(l);
vt[l]:=i;
end;
end;
for i := 1 to n - 1 do
for j := i + 1 to n do
if a[i] > a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('a.',' So lon nhat trong day la ',ma);
writeln('b.',' So luong so lon nhat la ',c);
writeln('c.',' So nho nhat trong day la ',mi);
write('d',' Vi tri cac so lon hon x la ');
for i := 1 to l do
write(vt[i],' '); writeln;
write('e.',' Day so tang dan ');
for i := 1 to n do
write(a[i],' ');
readln;readln;
end.
Bài 1:
program bai_giai;
uses crt;
var A:array[1..100] of integer;
n,i,dem:byte;
function ktnt(k:integer):boolean;
var j:integer;
begin
ktnt:=false;
if k<2 then exit;
for j:=2 to trunc(sqrt(k)) do
if k mod j=0 then exit;
exit(true);
end;
BEGIN
clrscr;
write('Nhap so luong phan tu: '); readln(n);
write('Nhap day: ');
for i:=1 to n do read(A[i]);
dem:=0;
for i:=1 to n do
if ktnt(A[i]) then
begin
write(A[i],' ');
dem:=dem+1;
end;
if dem=0 then write('Co ',dem,' so nguyen to')
else
begin
writeln;
write('Co ',dem,' so nguyen to');
end;
readln; readln;
END.
Bài 2:
program bai_giai;
uses crt;
var A:array[1..100] of integer;
n,i,j,dem:byte;
x,max,min,tg:integer;
begin
clrscr;
write('Nhap so phan tu: '); readln(n);
write('Nhap day: ');
for i:=1 to n do read(A[i]);
max:=A[1]; min:=A[1];
for i:=2 to n do
begin
if A[i]>max then max:=A[i];
if A[i]<min then min:=A[i];
end;
writeln('a. ',max);
dem:=0;
for i:=1 to n do
if A[i]=max then dem:=dem+1;
writeln('b. ',dem);
writeln('c. ',min);
write('d. Nhap x: '); readln(x);
for i:=1 to n do
if A[i]>x then write(i,' ');
writeln;
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('e. ');
for i:=1 to n do write(A[i],' ');
readln;
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 7 - Năm thứ hai ở cấp trung học cơ sở, một cuồng quay mới lại đến vẫn bước tiếp trên đường đời học sinh. Học tập vẫn là nhiệm vụ chính!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK