没错啊,编译及运行都没问题
var
i : integer ;
s1 , s2 : Array [0..9] of string ;
begin
for i := 0 to 9 do
s1[i] := inttostr(i);
for i := 0 to 9 do
s2[9-i] := inttostr(i);
if s1[8] = s2[1] then
showmessage('s1=s2')
else
showmessage('s1<>s2');
end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function CmpStr(const StrS, StrD: string): Boolean;
public
{ Public declarations }
end;
TStudentRec = record
No: string;
Name: string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
function TForm1.CmpStr(const StrS, StrD: string): Boolean;
var
i: Integer;
begin
Result := False;
if Length(StrS) <> Length(StrD) then Exit;
for i := 0 to Length(StrS) - 1 do
if StrS[i] <> StrD[i] then Exit;
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Str1, Str2: string;
begin
Str1 := 'abc';
Str2 := 'abc';
if CmpStr(Str1, Str2) then ShowMessage('相同')
else ShowMessage('不同');
end;