大家帮我看看这个问题,
编译老说array type required,谢谢!unit Umain;interfaceuses
  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.

解决方案 »

  1.   

    TColor=array[1..Country_Num] of 0..4;
                                    ~~~~哪有这么写的通常后面要写数据类型
      

  2.   

    TColor=array[1..Country_Num] of Integer;
      

  3.   

    改成integer还是那个错,
    不是这个原因
      

  4.   

    var  Form_Main: TForm_Main;
      Color:Tcolor;//这个TColor    和Graphics  单元的TColor 编译器知道是哪个TColor ??
      Country_Num_Input:Integer;
      

  5.   

    楼主没用过Delphi吧?编译报错应该提示你行号,你该能看到。前面的一个改了,你就不能把后面的也改了?
    Relation:array[1..Country_Num,1..Country_Num] of 0..1;
      

  6.   

    pazee(耙子)的意思是:
    TColor=array[1..Country_Num] of Integer;
    Relation:array[1..Country_Num,1..Country_Num] of Integer
      

  7.   

    定义数组的格式是:
    <数组名>:arrary[启始值..最终值] of 数组类型;所以,上面的就应该是
    Relation:array[1..4] of integer;
      

  8.   

    由于color定义为TColor,而i定义为integer
    所以 color[1]:=i 会出错。
      

  9.   

    不能那么定义!你Relation:array[1..4] of 0..4这样不行如果你想限制数组内的内容,你可以定义一个只有0..4的类型不能这么直接用,再说你的这个TColor是不是有和系统的类重名的嫌疑?
      

  10.   

    TColor=array[1..Country_Num] of 0..4; //与Graphics里面的TColor冲突
    //TColor改成 TMyColor
    -------
    var  Form_Main: TForm_Main;
      Color:Tcolor;  //Color改成 MyColor ,与Self.Color冲突  Country_Num_Input:Integer;
      

  11.   

    Type 
      TSetColor = Set of 0..1;
    .
    .
    .
    var
      Relation:array[1..Country_Num,1..Country_Num] of TSetColor;定义数组世需要类型标识的。
    把0..1定义了就可以