zoukankan      html  css  js  c++  java
  • 判断IP地址是否非法!

    判断IP地址是否非法的代码:

     1 function   TForm1.IsIPString(IPStr:   string):   Boolean;
    2 var
    3 i,DotNum:integer;
    4 Tmpstr:string;
    5 begin
    6 Result:=true;
    7 DotNum:=0;
    8 for i:=1 to Length(IPStr) do
    9 Case IPStr[i] of
    10 '0'..'9','.':
    11 begin
    12 if IPStr[i]<>'.' then
    13 begin
    14 Tmpstr:=Tmpstr+IPStr[i];
    15 if StrtoInt(tmpstr)>255 then
    16 begin
    17 Result:=False;
    18 exit;
    19 end;
    20 end
    21 else
    22 begin
    23 if (TmpStr='')and(DotNum>0) then //如果连续2个点的情况
    24 begin
    25 Result:=False;
    26 Exit;
    27 end;
    28 Tmpstr:='';
    29 DotNum:=DotNum+1;
    30 end;
    31 end;
    32 else
    33 begin Result:=false; exit; end;
    34 end;
    35 if DotNum<>3 then Result:=False;
    36 end;
  • 相关阅读:
    Codeforces 937D
    Codeforces 458C
    Codeforces 934D
    Codeforces 934C
    Codeforces 36B
    Codeforces 374C
    Codeforces 374D
    编译优化
    Codeforces E
    Codeforces 920G
  • 原文地址:https://www.cnblogs.com/prtmon/p/2382169.html
Copyright © 2011-2022 走看看