大家帮我看看这个问题,编译老说array type required,谢谢!
大家帮我看看这个问题,
编译老说array type required,谢谢!
unit Umain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids;
const Country_Num=20;
type
TColor=array[1..Country_Num] of 0..4;
TForm_Main = class(TForm)
btn_OK: TButton;
stg_Main: TStringGrid;
Label1: TLabel;
Edit_Num: TEdit;
RichEdit_Result: TRichEdit;
procedure Edit_NumChange(Sender: TObject);
procedure btn_OKClick(Sender: TObject);
private
procedure a_try(i:integer);
function proved(i,j:integer):boolean;
procedure print;
{ Private declarations }
public
{ Public declarations }
end;
var
Form_Main: TForm_Main;
Color:Tcolor;
Country_Num_Input:Integer;
implementation
{$R *.dfm}
var
Relation:array[1..Country_Num,1..Country_Num] of 0..1;
procedure TForm_Main.Edit_NumChange(Sender: TObject);
begin
try
stg_main.RowCount:=strtoint(Edit_Num.Text);
stg_main.ColCount:=strtoint(Edit_Num.Text);
except
on EConvertError do
messagebox(handle,'国家数要是整数','提示',MB_OK);
end;
end;
procedure TForm_Main.btn_OKClick(Sender: TObject);
var
Country1,Country2:integer;
begin
Country_Num_Input:=strtoint(Edit_Num.Text);
for Country1:=1 to Country_Num_Input do
begin
for Country2:=1 to Country_Num_Input
do Relation[Country1,Country2]:=strtoint(stg_Main.Cells[Country1,Country2]);
end;
for Country1:=1 to Country_Num_Input do
Color[Country1]:=0;//这里array type required
a_try(1);
end;
procedure TForm_Main.a_try(i: integer);
var
j:integer;
begin
for j:=1 to 4 do
begin
if proved(i,j) then
begin
Color[i]:=j;;//这里array type required
if i=Country_Num_Input then
print
else
a_try(i+1);
Color[i]:=0;;//这里array type required
end;
end;
end;
function TForm_Main.proved(i, j: integer): boolean;
var
k:integer;
begin
for k:=1 to i-1 do
if (Relation[i,k]=1) and (j=Color[k]) then;//这里array type required
begin
Result:=false;
exit;
end;
Result:=true;
end;
procedure TForm_Main.print;
var
k:integer;
s:string;
begin
s:='';
for k:=1 to Country_Num_Input do
begin
case Color[k] of;//这里array type required
1:s:=s+'R ';
2:s:=s+'B ';
3:s:=s+'W ';
4:s:=s+'Y ';
end;
end;
RichEdit_Result.Lines.Append(s);
end;
end.