♣
删除重复的字符串行
编程问题:如何在一个文本文件(如txt)中,比较n行字符, 删除重复的字符串行,请见示例:
this is a test.
this is a test.
this is another test.
this is another test.
this is another test.
this is a test.
this is a test.
this is another test.
删除其中重复的内容,变成:
this is a test.
this is another test.
· 网友精彩回答:
procedure tform1.button1click(sender: tobject);
var
sw:boolean;
i,cou:integer;
s:string;
fulltxt,newfulltxt:tstringlist;
begin
fulltxt := tstringlist.create;
newfulltxt := tstringlist.create;
fulltxt.loadfromfile(abc.txt);
for i :=0 to fulltxt.count-1 do
begin
sw:=false;
s:= fulltxt.strings[i];
if i=0 then
begin
newfulltxt.add(s);
continue;
end;
for cou := 0 to newfulltxt.count-1 do
if ansisamestr(s,newfulltxt.strings[cou]) then
sw := true;
if not sw then
newfulltxt.add(s);
end;
newfulltxt.savetofile(abc.txt);
end;
- 更多问题:
- · 可恶的IE......
- · 求教oracle监听器与jsp冲突
- · 未将对象引用设置到对象的实例。
- · 请问,怎么把一个datatable存到换存中呢?
- · 我要用java 的相关技术做心跳检测的客户端,和用户的上下线请请求,知道原理的请进
- · 关于框架页面中如何实现基于表单的验证???特急!!
- · 怎样设置listview(report)控件选定的行的背景色
- · 大家帮我看看强类型DataSet的问题吧
- · 拜师学艺!!!
- · 疑惑重重的Eclipse的SWT包
- · 怎样在一个HTTP接收缓冲区(1024),准确的解析头信息
- · oracle监听器与jsp冲突
- · **如何讓一個INPUT控件中按回車鍵但不讓他做頁面的提交的動作????
- · 看资本家的猖狂!看“白领”的悲哀!!
- · 关于SQL语句不懂的地方,请教
- · 请问怎么用javascript实现热键的操作?比如按 Ctrl + 5 实现激发一个函数!

