1,在Delphi中如何在文本文件中獲取一行,一個單詞,一個字符?有現成的函數嗎?
2,在Delphi中如何實現一個雙向鏈表的插入和刪除?要是能過通過編譯的程序代碼。

解决方案 »

  1.   

    1、直接用TStringList类
    StringList.LoadFromFile('ice.txt');
    这样可以访问它的一行
    StringList.Strings[2];2、如果没有必要的话
    你可以试试用TList去实现你的功能
    否则只有自己写双向链表
      

  2.   

    procedure TForm1.BitBtn6Click(Sender: TObject);
    var
      FileName : TextFile;
      Str,Tmp : String;
      TStrList : TStringList;
      i,k : Integer;
    begin
      TStrList := TStringList.Create;
      TStrList.Clear;
      if not (FileExists(GetNameDir(Application.ExeName)+'xuanhao.txt')) then
      begin
        Application.MessageBox('xuanhao.txt文件不存在,请先转出TXT文件','提示',MB_OK+MB_ICONSTOP);
        Exit;
      end;
      AssignFile(FileName,GetNameDir(Application.ExeName) + 'xuanhao.txt');
      Reset(FileName);
      Readln(FileName,Str);
      CloseFile(FileName);
      if Str <> '' then
      begin
        i := pos(',',str);
        while i > 0 do
        begin
          Tmp := copy(Str,1,i - 1);
          TStrList.Add(Tmp);
          Str := copy(Str,i + 1,length(Str)-i);
          i := pos(',',Str);
        end;
        if Str <> '' then
        begin
          TStrList.Add(Str);
        end;
      end;
      for k := 0 to TStrList.Count - 1 do
      begin
        if StrToInt(TStrList.Strings[k]) > StrToInt(Edit2.Text) then
        begin
          Application.MessageBox('参数设置有误,请重新设置','提示',MB_OK+MB_ICONSTOP);
          Exit;
        end;
        setlength(selected,k + 1);//初始化数组
        selected[k] := StrToInt(TStrList.Strings[k]);
      end;
    end;
      

  3.   

    題目:設計一個雙向鏈表:給出資料結構的定義,並給出插入、刪除的演算法。
    雙向鏈表的結構如下:
    type
    PNode=^TNode;
    TNode=Record
      ElemValue:string;
      prior:PNode;
      next:PNode;
    end;
      

  4.   

    1、直接用TStringList类
    StringList.LoadFromFile('x.txt');
    这样可以访问它的一行
    StringList.Strings[2];
    2
    type
    PNode=^TNode;
    TNode=Record
      ElemValue:string;
      prior:PNode;
      next:PNode;
    end;
    剩下的看一下数据结构