1,在Delphi中如何在文本文件中獲取一行,一個單詞,一個字符?有現成的函數嗎?
2,在Delphi中如何實現一個雙向鏈表的插入和刪除?要是能過通過編譯的程序代碼。
2,在Delphi中如何實現一個雙向鏈表的插入和刪除?要是能過通過編譯的程序代碼。
解决方案 »
- excel数据导入sqlserver2000数据库的问题.
- 怎样让下拉菜单显示数据库中的数据
- 一个简单的qreport报表问题
- 问题讨论 进来看看 up有分
- 关于TXMLDocument的DOMVendor属性值的添加使用
- Borland Delphi 6 中文企业版哪里有免费下载????????????????????500分
- 数据类型问题:
- 求能在下拉框中显示treeview的combobox控件
- 请教如何调用帮助文档!
- Delphi中怎样保存断点?家里用Access2000+ADO+delphi,到了学校机房还要手工配置吗(学校只有Access97).
- 关于QUERY的简单SQL语句。
- 在vb里的代码是chr$(5),在delphi里与其等价的代码是什么?
StringList.LoadFromFile('ice.txt');
这样可以访问它的一行
StringList.Strings[2];2、如果没有必要的话
你可以试试用TList去实现你的功能
否则只有自己写双向链表
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;
雙向鏈表的結構如下:
type
PNode=^TNode;
TNode=Record
ElemValue:string;
prior:PNode;
next:PNode;
end;
StringList.LoadFromFile('x.txt');
这样可以访问它的一行
StringList.Strings[2];
2
type
PNode=^TNode;
TNode=Record
ElemValue:string;
prior:PNode;
next:PNode;
end;
剩下的看一下数据结构