研究了一下,834多万组合加上显示0.49秒,给分吧
(P4,2.8G ,512M内存)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
const int TOTALKINDS = 8347680;
LARGE_INTEGER litmp;
LONGLONG QPart1,QPart2;
double dfMinus, dfFreq, dfTim;
QueryPerformanceFrequency(&litmp);
dfFreq = (double)litmp.QuadPart;// 获得计数器的时钟频率
QueryPerformanceCounter(&litmp);
QPart1 = litmp.QuadPart;// 获得初始值
int icount = 0;
zhuhe *a = new zhuhe[TOTALKINDS];
int xiabiao = 0;
for (int i = 0
i<30
i++)
{
for (int j = i+1
j<31
j++)
{
for (int k = j+1
k<32
k++)
{
for (int l = k+1
l<33
l++)
{
for (int m = l+1
m<34
m++)
{
for (int n = m+1
n<35
n++)
{
for (int o= n+1
o<36
o++)
{
a[xiabiao].i1 = i;
a[xiabiao].i2 = j;
a[xiabiao].i3 = k;
a[xiabiao].i4 = l;
a[xiabiao].i5 = m;
a[xiabiao].i6 = n;
a[xiabiao].i7 = o;
xiabiao++;
icount++;
}
}
}
}
}
}
}
randomize();
int j=0;
for (int i = 0
i<100
i++)
{
j = random(TOTALKINDS);
Memo1->Lines->Add(IntToStr(a[j].i1)
+","+IntToStr(a[j].i2)
+","+IntToStr(a[j].i3)
+","+IntToStr(a[j].i4)
+","+IntToStr(a[j].i5)
+","+IntToStr(a[j].i6)
+","+IntToStr(a[j].i7));
}
delete a;
QueryPerformanceCounter(&litmp);
QPart2 = litmp.QuadPart;//获得中止值
dfMinus = (double)(QPart2-QPart1);
dfTim = dfMinus / dfFreq;// 获得对应的时间值,单位为秒
Label1->Caption = (String)(dfTim);
Label2->Caption = (String)(icount);
}