比如在两个输入框中输入:
135.35.1.1
135.36.1.2则输出:
135.35.1.1
135.35.1.2
135.35.1.3
……
135.35.1.254
135.35.1.255
135.36.1.0
135.36.1.1
135.36.1.2另外,如果我用一个数组把所有合法可能的IP地址放在这个数组里,能装得下吗?会不会有什么问题?

解决方案 »

  1.   

    把2个ip转为4字节整数a,b
    for i:=a to b do
      输出:把i转为ip
      

  2.   

    给你个思路,就是先把两个ip地址四段分拆变为四个整数,然后对比~~
    对比后,各段若有不同值,将其记录下来,接下来就是根据记录的数据,输出IP地址了~~
      

  3.   

    把点分隔的IP地址转换成32位的整数后再处理就容易了。
    uses StrUtils;function IPToDWORD(sIP: String): DWord;
    var
      a: array [0..3] of Byte;
      i, j, k: Integer;
    begin
      i := 0;
      for k := 3 downto 1 do
      begin
        a[k] := 0;
        j := PosEx('.', sIP, i + 1);
        if j > i then
        begin
          a[k] := StrToIntDef(Copy(sIP, i + 1, j - i - 1), 0);
          i := j;
        end;
      end;
      a[0] := StrToIntDef(Copy(sIP, i + 1, Length(sIP) - i), 0);
      Move(a[0], Result, 4);
    end;function DWORDToIP(iIP: DWORD): String;
    var
      a: array [0..3] of Byte;
      i: Integer;
    begin
      Move(iIP, a[0], 4);
      Result := IntToStr(a[3]);
      for i := 2 downto 0 do
        Result := Result + '.' + IntToStr(a[i]);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      i : DWORD;
    begin
      for i := IPToDWORD('135.35.1.1') to IPToDWORD('135.35.2.1') do
        Memo1.Lines.Add (DWORDToIP(i));
    end;
      

  4.   

    Move 真是太神奇了,竟然可以这样用.