📄 unit4.~pas
字号:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TForm4 = class(TForm)
Button1: TButton;
Memo1: TMemo;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
ProgressBar1: TProgressBar;
Memo2: TMemo;
Memo3: TMemo;
Memo4: TMemo;
Memo5: TMemo;
Memo6: TMemo;
Label6: TLabel;
Label7: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
var i:integer;
a:Array[0..9] of integer=(2,5,6,2,6,1,7,3,9,4);
b:Array[0..9] of string;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
//Randomize;//每次随机数就不一样
for i:=0 to 9 do
begin
//a[i]:=random(10); //每次随机数
b[i]:=inttostr(a[i]);
memo1.Lines.Add('');
memo1.Lines.Add(b[i]);
end;
end;
procedure TForm4.Button2Click(Sender: TObject);
var n,k:integer;
begin
if form4.RadioButton1.Checked then
begin
for n:=0 to 9 do
begin
if n=0 then
begin
label6.Caption:='正在访问 2 ' ;
memo2.Lines.Add(b[n]);
label7.Caption:=' 2 放入内存物理块1中' ;
end;
if n=1 then
begin
label6.Caption:='正在访问页面 5 ' ;
memo3.Lines.Add(b[n]);
label7.Caption:=' 5 放入内存物理块2中' ;
end;
if n=2 then
begin
label6.Caption:='正在访问页面 6 ' ;
memo4.Lines.Add(b[n]);
label7.Caption:=' 6 放入内存物理块3中' ;
end;
if n=3 then
begin
label6.Caption:='正在访问页面 2 ' ;
label7.Caption:=' 2 已经存在内存中' ;
end;
if n=4 then
begin
label6.Caption:='正在访问页面 6 ' ;
label7.Caption:=' 6 已经存在内存中' ;
end;
if n=5 then
begin
label6.Caption:='正在访问页面 1 ' ;
memo5.Lines.Add(b[n]);
label7.Caption:=' 1 放入内存物理块4中' ;
end;
if n=6 then
begin
label6.Caption:='正在访问页面 7 ' ;
memo6.Lines.Add(b[n]);
label7.Caption:=' 7 放入内存物理块5中' ;
end;
if n=7 then
begin
label6.Caption:='正在访问页面 3 ' ;
memo3.Lines.Add(b[n]);
label7.Caption:='物理块2的页面5换出 3放入' ;
end;
if n=8 then
begin
label6.Caption:='正在访问页面 9 ' ;
memo2.Lines.Add(b[n]);
label7.Caption:='物理块1的页面3换出 9放入' ;
end;
if n=9 then
begin
label6.Caption:='正在访问页面 4 ' ;
memo4.Lines.Add(b[n]);
label7.Caption:='物理块3的页面6换出 4放入' ;
end;
ProgressBar1.Min:=0; ProgressBar1.Max:=350;
for k:=1 to 350 do
begin
ProgressBar1.Position:=k;
Application.ProcessMessages;
sleep(10);
end;
end;
end;
end;
procedure TForm4.Button3Click(Sender: TObject);
begin
memo1.Clear;
memo2.Clear;
memo3.Clear;
memo4.Clear;
memo5.Clear;
memo6.Clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -