Chủ đề nóng: Phương pháp kỷ luật tích cực - Cổ học tinh hoa - Những thói hư tật xấu của người Việt - Công lý: Việc đúng nên làm - Giáo án Điện tử - Sách giáo khoa - Học tiếng Anh - Bài giảng trực tuyến - Món ăn bài thuốc - Chăm sóc bà bầu - Môi trường - Tiết kiệm điện - Nhi khoa - Ung thư - Tác hại của thuốc lá - Các kỹ thuật dạy học tích cực
- Dạy học phát triển năng lực - Chương trình giáo dục phổ thông
UserWiki:Nxthai
Từ VLOS
Bài giải đề thi tin học trẻ huyện Thuận An năm 2009
Bài 1 var n:integer; function kt(n:integer):integer; var i:integer;
begin
i:=2;
if n=1 then kt:=0
else
begin
while i<=trunc(sqrt(n)) do
begin
if n mod i=0 then break
else i:=i+1;
end;
if i>trunc(sqrt(n)) then kt:=1
else kt:=0;
end;
end;
begin
n:=7000;
while n<9000 do
begin
if kt(n)=1 then write(n,' ');
n:=n+1;
end;
readln;
end.
Bài 2 Chú ý bài số 2 phải tồn tại fileint chứa từng dòng như bên dưới, còn fileout tự nó sẽ tạo ra ví dụ fileint.txt fileout.txt
14 14 = 13 + 1 20 20 = 13 + 5 + 2 17 17 = 13 + 3 + 1 49 49 = 34 + 13 + 2
Lời giải var m:integer;
fi,fo:text;
function f(n:integer):integer;
begin
if (n=1)or(n=2) then f:=1
else f:=f(n-1)+f(n-2);
end;
function test(m:integer):integer; var n:integer;
begin
n:=1;
while m>f(n) do n:=n+1;
if m=f(n) then test:=0
else test:=n;
end;
procedure tong(m:integer);
begin
if test(m)=0 then writeln(fo,m,' ')
else
begin
write(fo,f(test(m)-1),' + ');
tong(m-f(test(m)-1));
end;
end;
begin
assign(fi,'C:\fileint.txt');
assign(fo,'C:\fileout.txt');
reset(fi);rewrite(fo);
while not eof(fi) do
begin
readln(fi,m);
write(fo,m,' = ');
tong(m);
end;
close(fo);
writeln('chuong trinh da thuc hien xong');
readln;
end. Bài 3 var a:array[1..10,1..10] of integer;
m,n,i,j:integer;
function min(m:integer):integer; var i,gt:integer;
begin
gt:=a[m][1];
for i:=2 to n do
if a[m][i]<gt then gt:=a[m][i];
min:=gt;
end;
function max(n:integer):integer; var i,gt:integer;
begin
gt:=a[1][n];
for i:=2 to m do
if a[i][n]>gt then gt:=a[i][n];
max:=gt;
end;
begin
write('Nhap so dong ');readln(m);
write('Nhap so cot ');readln(n);
for i:=1 to m do
for j:=1 to n do
begin
write('a[',i,j,'] = ');
readln(a[i][j]);
end;
for i:=1 to m do
for j:=1 to n do
if max(j)=min(i) then writeln(a[i][j],' la phan tu yen ngua ');
readln;
end.
