请问你一个最最简单的小小的问题:)(10分)

衫菜

Unregistered / Unconfirmed
GUEST, unregistred user!
VAR
ASTR:SRTNIG;

我怎么判断ASTR是否是'AB','BA','AA'这三个字符串中的一个呢?
不能用if astr='ab' or astr='ba' or astr='aa' then这种方法,
有办法吗???
 
if comparestr(astr,'AB')=0 then 相等
 
要投机取巧了。。。
const
LIST = 'AB,BA,AA';
var
astr: string;
begin
astr := 'AA';
if Pos(astr, LIST) mod 3 = 1 then
...
end;
 
补充上面的:

if (length(astr)=2) and (Pos(astr, LIST) mod 3 = 1) then
 
多人接受答案了。
 
顶部