flag:=true;
for i:=0 to 15 do 
begin
     if ((i mod 2)=0) then flag:=flag and (buf[i]=$E)  //???
     else flag:=flag and (buf[i]=$B);  //????
     if not flag then break;
end;

解决方案 »

  1.   

    buf 这个变量你的程序里面没有说明是什么鸟东东,你叫我们怎么看呀
      

  2.   

    判断某个长度为16的字符数组是否为[$E,$B,$E,$B,...,$E,$B]
      

  3.   

    flag:=true;
    for i:=0 to 15 do 
    begin
         if ((i mod 2)=0) then 
            flag:=flag and (buf[i]=$E)  //???
         else 
            flag:=flag and (buf[i]=$B);  //????
         if not flag then 
            break;
    end;
    flag and (buf[i]=$E)和flag and (buf[i]=$E)都是一个表达式
    返回值是布尔型的.
    就象
    False and True返回值是False一样
      

  4.   

    实际上这段程序故弄玄虚.
    既然if not flag then 
            break;
    那还用得着比较什么直接改成
    flag:=true;
    for i:=0 to 15 do 
    begin
         if ((i mod 2)=0) then 
            flag:=(buf[i]=$E)  //???
         else 
            flag:=(buf[i]=$B);  //????
         if not flag then 
            break;
    end;
    这样就明白多了
      

  5.   

    wr960204(武稀松),那flag什么时候会为false呢?
      

  6.   

    其实这段程序的效果就是如 forgot(让一切随风) 所说,来判断16个字符的Buf的内容,但我看不明白为什么会达到这个效果,不是 EBEB…就跳出