Bài 3
uses crt;
type int = longint;
var i,j,n,tmp,x:int;
a:array[0..100000] of int;
procedure print_arr(a:array of int;n:int);
var i:int;
begin
for i:=1 to n do write(a[i],' ');
writeln;
end;
begin
clrscr;
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i] < a[j] then
begin
tmp:=a[i];
a[i]:=a[j];
a[j]:=tmp;
end;
print_arr(a,n);
readln(x);
for i:=n downto 0 do
if a[i] > x then
break;
inc(i);
for j:=n downto i do
a[j+1]:=a[j];
a[i]:=x;
print_arr(a,n+1);
readln;
end.
Bài 4
uses crt;
type int = longint;
var c:array[0..1000000] of boolean;
i,n:int;
procedure sieve(n:int);
var i,j:int;
begin
for i:=2 to trunc(sqrt(n)) do
if not c[i] then
for j:=i to n div i do
c[i*j]:=true;
end;
begin
clrscr;
readln(n);
sieve(n);
for i:=n downto 1 do
if (n mod i = 0) or not(c[i]) then
write(i,' ');
readln;
end.
Câu 3:
program baicuaban;
Var a:array [1..100] Of integer;
k,n,i,tam,x:integer;
Begin
Write('Nhap so phan tu n:');
ReadLn(n);
For i:=1 to n do
Begin
Bài 4:
Var a: array[1..1000]of integer;
i,j,k,n,d:integer;
kt:boolean;
function nt(n:longint):boolean;
var i:longint;
begin
if n<2 then nt:=false
else begin
i:=2;
while (i<=sqrt(n)) and (n mod i<>0) do inc(i);
nt:=(i>sqrt(n));
end;
end;
BEGIN
clrscr;
write('vao n=');readln(n);
if n=2 then write(n,' ',1)
else
begin
d:=1; a[1]:=n;
for i:= n-1 downto 1 do
begin
if(nt(i)) then begin inc(d);a[d]:=i;a[d]:=i;end
else
begin
kt:=false;
for j:=1 to d-1 do
if a[j] mod i=0 then kt:=true;
if kt then begin
inc(d);
a[d]:=i;
end;
end;
end;
for i:=1 to d do write(a[i],' ');
end;
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