我现在已经定义了一个字符串数组n,n[122],但是里面有重复的元素,我想把重复的数据剔除掉,写了一个程序,执行没有错误,但是就是删除不了。达人们帮我看下啊//剔除数组n中重复的数据,并赋值给数组b b[1]:=n[1];
m:=0;
for i:=1 to 122 do
begin
for j:=1 to m do
begin
if n[i]=b[j] then
begin
break;
end
else
begin
continue;
end;
end;
m:=m+1;
b[m]:=n[i];
end;
m:=0;
for i:=1 to 122 do
begin
for j:=1 to m do
begin
if n[i]=b[j] then
begin
break;
end
else
begin
continue;
end;
end;
m:=m+1;
b[m]:=n[i];
end;
解决方案 »
- MemoClick怎么来的?
- 请帮我给我们的小程序员起个名字!!!
- 如何在memo 或则 richedit 上 添加,使用 radiobutton 和 checkbox 控件
- 武汉招聘用ASP, DELPHI的程序员,
- 如何在dxDBTreeView和dxDBLookupTreeView中获取选中项的ID?
- 有关于SQL统计问题
- 我的这个托盘程序为什么在任务栏中有图标,但是窗体确是最小化的
- 在Delphi中如何实现补码运算?(急!)
- DBGrid
- 谁有例子:关于跟踪windows内任一程序对注册表的操作。
- 向Query插入大量数据的性能问题.
- 删除DBGrid中的记录的同时数据库中的记录也被删除
N: array[0..122-1] of Integer;
i,J,K,Count: Integer;
begin
//仅用于生成测试数据
for I := 0 to Length(N) - 1 do begin
Randomize;
N[I] := Random(3124124);
end; Count := Length(N);
for I := 0 to Count - 1 do begin
for J := I+1 to Count - 1 do begin
if N[I] = N[J] then begin
K := J + 1;
while K < Count do begin
N[K-1] := N[K];
Inc(K);
Dec(Count);
end;
end;
if J >= Count then Break;
end;
if I >= Count then Break;
end;end;
existflag:boolean;
b[1]:=n[1];
m:=0;
for i:=1 to 122 do
begin
existflag:=false;
for j:=1 to m do
begin
if n[i]=b[j] then
begin
existflag:=true;
break;
end;
end;
if not existflag
begin
m:=m+1;
b[m]:=n[i];
end;
end;
existflag:boolean; 數組是以Index是以0開始
b[0]:=n[0];
m:=0;
for i:=1 to 122-1 do
begin
existflag:=false;
for j:=0 to m do
begin
if n[i]=b[j] then
begin
existflag:=true;
break;
end;
end;
if not existflag
begin
m:=m+1;
b[m]:=n[i];
end;
end;