小弟我写了段代码,但编译报错declaration expected but end of file found.怀疑是声明函数时格式不对,哪位大虾给看看!program Project2;uses
  SysUtils,
  math;{$APPTYPE CONSOLE}
const M = 10;
      N = 10;
      Min = 100; //最小分配大小
Type
AMem = record
name : array[0..10] of Char;
address : integer;
size : integer;
flag : integer;
//1:used,0:no have
end;RMem = record
address : integer;
size : integer;
flag : integer;
//1:empty , 0:nohave
end;var aamem : array[0..M] of AMem ;
    rrmem : array[0..N] of RMem ;
procedure ini();
function allocate(name : PChar ; size : integer):Boolean;
function reclaim(name : PChar):Boolean;
procedure output();
procedure ini();
var i : integer;
begin
rrmem[0].address := 0;
rrmem[0].size := 10000;
rrmem[0].flag := 1;
for i := 1 to M-1 do
begin
  rrmem[i].flag:=0;end;
for i := 0 to N-1 do
begin
  aamem[i].flag:=0;
  
end;
end;
//optimization fit arithmetic
function allocate(name : PChar ; size : integer):Boolean;
var i,j,min,trackr,tracka,sum : integer;
begin
i := 0;
j := 0;
trackr := -1;
tracka := -1;
sum := 0;
//search the first empty node from allocate\'s table
repeat
  if aamem[j].flag = 0 then
  begin
   tracka := j;
   break;
  end;
  inc(j);
until j>=M ;
//search endif tracka = -1 then
  result := false;//search the first empty node from reclaim\'s table
repeat
  if rrmem[i].flag = 1 then
  begin
   trackr := i;
   break;
  end;
  inc(i);
until  i>=M ;
//seache end//account how many empty block of memory 
j:=0;
repeat
  if rrmem[j].flag = 1 then
   inc(sum);
  inc(j);
until j>=M ;
if sum = 0 then
  result := false;
//account end//seek whether enough have a block memory
//if not return false
j := 0;
repeat
  if rrmem[j].flag = 1  then
   if rrmem[j].size < size then
    inc(j)
   else
   break;
until  j >= sum ;
if j = sum then
  result := false;
//end seekmin := Abs(size - rrmem[i].size);
repeat
  inc(i);
  if rrmem[i].flag = 1 then
   if min<abs(size - rrmem[i].size) then
    trackr := i;
until  i>=M ;//if not found the fitting node
if trackr = -1  then
  result := false
else
begin
  //change the reclaim\'s table
  //if the apply size less than Min(100)
  if size <= Min then
  begin
   rrmem[trackr].flag := 1;   aamem[tracka].address := rrmem[trackr].address;
   //change the address of reclaim\'s table
   //advert the position
   rrmem[trackr].address := rrmem[trackr].address + size;
   rrmem[trackr].size := Abs(rrmem[trackr].size-size);   //change the allcoate\'s table start
   StrCopy(aamem[trackr].name, name);
   aamem[tracka].flag := 1;
   aamem[tracka].size := size;
   //change the allcoate\'s table end
   result := true;
  end  else
  begin
   //change the reclaim\'s table start
   rrmem[trackr].flag:= 1;   //change the address of reclaim\'s table
   //advert the position
   aamem[tracka].address:= rrmem[trackr].address;
   //change the address of reclam\'s table end   rrmem[trackr].address := rrmem[trackr].address + size;
   rrmem[trackr].size:= Abs(rrmem[trackr].size - size);
   //change the reclaim\'s table end   //change the allocate\'s table start
   Strcopy(aamem[tracka].name, name);
   aamem[tracka].flag := 1;
   aamem[tracka].size := size;
   //change the allocate\'s table end
   result := true;
 end;
end;
end;function reclaim(name : PChar):Boolean;
var tag : Boolean;
    i : integer;
    tracka : integer;
begin
tag := false;
i := 0;
tracka := -1;
//search the node of want to reclaim
repeat
  if aamem[i].flag = 1 then
   begin
   if not StrComp(aamem[i].name, name) = 0 then
    begin
    tracka := i;
    break;
   end;
  end;
  inc(i);
until i >= M;
//if didn\'t find. return false
if tracka = -1 then
 result := false;//if up and down have no empty block memory
if (aamem[tracka-1].flag = 1) and (aamem[tracka+1].flag = 1)  then
 begin
  //change the table of allocate
  aamem[tracka].flag := 0;
  //change the table of reclaim
  rrmem[tracka].flag := 1;
  
  tag := true;
end;//if up have empty block memory
if (aamem[tracka-1].flag = 0) and (aamem[tracka+1].flag = 1)  then
  begin
  //change the table of allocate
  aamem[tracka].flag := 0;
  //change the table of reclaim
  rrmem[tracka-1].size := rrmem[tracka-1].size+aamem[tracka].size;
  rrmem[tracka].flag := 1;
  rrmem[tracka].size := 0;  tag := true;
end;//if down have empty block memory
if (aamem[tracka+1].flag = 0) and (aamem[tracka-1].flag = 1) then
  begin
  //change the table of allocate
  aamem[tracka].flag := 0;
  //change the table of reclaim
  rrmem[tracka].flag := 1;
  rrmem[tracka].size := rrmem[tracka].size+rrmem[tracka+1].size;
  rrmem[tracka+1].size := 0;  tag := true;
end;//if down and up both have the empty block memory
if (aamem[tracka+1].flag = 0) and (aamem[tracka-1].flag = 0)  then
 begin
  //change the table of allcocate
  aamem[tracka].flag := 0;
  //change the table of reclaim
  rrmem[tracka].flag := 0;
  rrmem[tracka-1].size := rrmem[tracka-1].size+rrmem[tracka].size+rrmem[tracka].size;
  rrmem[tracka].size := 0;
  rrmem[tracka+1].size := 0;  tag := true;
end;
result := tag;
end; procedure output();
 var i : integer;
 begin
writeln('Process name     Start address        Size');
for i := 0 to M-1 do
  begin
  if aamem[i].flag = 1  then
   begin
writeln(aamem[i].name,'         ',aamem[i].address,'          ',aamem[i].size )
  end;
 
end;
writeln('');
end;
 var name : array[0..10] of Char;
    count,choose ,size : integer;
    ok : Boolean;
begin   { TODO -oUser -cConsole Main : Insert code here }
    ini();
    count := 0 ;
while count<9 do
begin
  writeln('Choose you want to do');   writeln('0: exit    1: allocate    2: reclaim    3: output');
  ReadLn(choose);
 case choose of  0:begin
  exit;
  break;
  end;
  1:begin
  writeln('input the process name: ');
   ReadLn(name);
  writeln('input the process size: ');
   ReadLn(size);
   ok := allocate(name, size);
   if ok then
    writeln('allcoate successful!')
   else begin
    writeln('allocate unsuccessful!');
   break;
   end;
   end;
  2:begin
   writeln('input the process name: ');
   ReadLn(name);
   ok := reclaim( name );
   if ok then
    writeln('reclaim is successful! ')
   else begin
    writeln('reclain is unsucssful!');
   break;
   end;
   end;
  3:begin
   writeln('About infomation:');
   output();
   break;
   end;
  else begin
   writeln('Not have choose');
   break;
   end;
  end;
  inc(count);
  end;
   end;
 end.