如何解决啊?(100)

H

huxhang

Unregistered / Unconfirmed
GUEST, unregistred user!
"10BET","01",,"1","0""10BET","02","3",,"0""10BET","03","3",,"0""10BET","04",,"1","0""10BET","05","3",,"0""10BET","06",,"1","0""10BET","07","3",,"0""10BET","08","3",,"0""10BET","09","3",,"0""10BET","10","3",,"0""10BET","11","3","1","10BET","12",,"1","0""10BET","13",,"1","0""10BET","14","3",,"0""24hPoker","01","3",,"0""24hPoker","03","3","1","24hPoker","04","3","1","24hPoker","05","3",,"0""24hPoker","06",,"1","0""24hPoker","07",,"1","0""24hPoker","08","3",,"0""24hPoker","09","3","1","24hPoker","10","3","1","24hPoker","11","3","1","24hPoker","12","3",,"0""24hPoker","13",,"1","0""24hPoker","14",,"1","0""5 Dimes","02",,"1","0""5 Dimes","03","3","1","5 Dimes","04","3",,"0""5 Dimes","05","3","1","5 Dimes","06","3",,"0""5 Dimes","07","3",,"0"(还有1000多行,一般都每14行第一列的内容相同,第2列从01-14, 第3,4,5列的内容是3或1或0或空)以上的text文件内容如何变成下面这样?10BET:10,30,30,10,30,10,30,30,30,30,31,10,10,30 //注意这一行是10BET的14行演变的24hPoker:30,*,31,31,30,10,10,30,31,31,31,30,10,10 //注意这一行是24hPoker的14行演变的5 Dimes:*,10,31,30,31,30,30,*,*,*,*,*,10,* //注意这一行是5 Dimes的6行演变的:其中01,08,09,10,11,12,14行没有就用*代替,100分求源代码
 
W

wangdonghai

Unregistered / Unconfirmed
GUEST, unregistred user!
假如文件名为1.txt...implementation{$R *.dfm}var g_SA1214:array[1..14] of string;procedure FenXi(sList,dList,SpLitList:TStrings);var s,sPreFix,sIndex,sValue:string
i:integer
procedure Split(s:string)
begin SpLitList.Clear
SplitList.Delimiter:=','
SplitList.DelimitedText:=s
end
function GetValue:string
begin result:=IntToStr(StrToInt( trim(SpLitList.Strings[2])+ trim(SpLitList.Strings[3])+ trim(SpLitList.Strings[4])))
end
procedure InitSA1214
var t:integer
begin for t:=1 to 14 do g_SA1214[t]:='*'
end
function GenRs:string
var t:integer
begin result:=sPreFix+' : '+g_SA1214[1]
for t:=2 to 14 do result:=result+', '+g_SA1214[t]
end;begin if sList.Count<=0 then exit
dList.Clear
s:=sList.Strings[0]
if s='' then exit
Split(s)
sPreFix:=SpLitList.Strings[0]
sIndex:=SpLitList.Strings[1]
sValue:=GetValue
InitSA1214
g_SA1214[StrToInt(sIndex)]:=sValue
for i:=0 to sList.Count-1 do begin s:=sList.Strings
if s='' then continue
Split(s)
sIndex:=SpLitList.Strings[1]
sValue:=GetValue
if Pos(sPreFix,s)=0 then begin dList.Add(GenRs)
sPreFix:=SpLitList.Strings[0]
InitSA1214
end
g_SA1214[StrToInt(sIndex)]:=sValue
end
dList.Add(GenRs);end;procedure TForm1.Button1Click(Sender: TObject);var sList,SplitList:TStringList;begin sList:=TStringList.Create
try sList.LoadFromFile('1.txt')
SpLitList:=TStringList.Create
try FenXi(sList,Memo1.Lines,SpLitList)
finally SpLitList.Free
end
finally sList.Free
end;end;
 
H

huxhang

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢!请加qq305698256
 

Similar threads

S
回复
0
查看
931
SUNSTONE的Delphi笔记
S
S
回复
0
查看
755
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部