如题所说

解决方案 »

  1.   

    呵呵
    谢谢 windindance(风舞轻扬)
      

  2.   

    windindance(风舞轻扬) 的算法叫随机吗?仅仅是无序吧
      

  3.   

    用你電腦中的當前時間(包括Y,M,D,S),API:GetSystemTime(LPSYSTEMTIME lpSystemTime);
      

  4.   

    我不认同 windindance(风舞轻扬) 的说法
    我也没有更好的办法GZ
      

  5.   

    我有C代码,要不要?
    BCB5.0编译通过.
      

  6.   

    void TFormMain::randdata()
    {
        randomize();
        int code;
        int i,num=Form4->ListBox1->Items->Count,index,count;
        for (i=0;i<Form4->ListBox1->Items->Count;i++)
         card[i]=0;
        for (code=1;code<=Form4->ListBox1->Items->Count;code++)
        {
        index=rand()%num;
        count=0;
        for (i=0;i<Form4->ListBox1->Items->Count;i++)
        {
         if (card[i]==0)
         {
          if (count==index)
          {
          card[i]=code;
          break;
          }
          count++;
         }
        }
        num--;
        }
        card[Form4->ListBox1->Items->Count]=2000;
    }
      

  7.   

    如果机器有网卡,可以生成GUID,是唯一的随机串
      

  8.   

    先定义一个TStringList变量,在往它里面写数据时去掉重复值,再将该变量的数据赋给数组,这样可以让系统自动去除重复值。
      

  9.   

    procedure Countnum(var a:array of integer); var
     len:integer;
     i, Index: Integer;
     temp:array of integer;begin len:=length(a);
     setlength(temp,len); for i:=0 to high(temp) do temp[i]:=i+1;
    //如果想要数值从0开始则temp[i];=i;
     while Len>0 do
     begin
       Index:=Random(Len);
       a[high(a)+1-Len]:=temp[Index];
       temp[Index]:=temp[Len-1];
       Len:=len-1;
     end
    end;
      

  10.   

    上面的方法不好,当数据越来越多时通过比较判断是否重复效率越来越低首先固定范围的随机数就可以理解为是从一个有序的数组中取的那么很简单,以1-100为例,定义数组n: array[0..99] of Integer,第一次任意取数,然后交换取得的数n[i]和最后一个数n[99],然后第二次从0-98中取数,再交换换取得的数n[i]和n[98],依此类推...
      

  11.   

    赞成 ehom(?!) 的方法,可能是速度最快的了
      

  12.   

    偶用的也有EHOM的方法,但此方法只适合于数量不大时,数量大时,且又不需要所有的数据,这样就太浪费了