function TForm1.gettime: double;
var int1,int2:int64;
begin
QueryperformanceCounter(int1);
Queryperformancefrequency(int2) ;
result:=int1/int2;
end;
以上这个函数计算开机以来的时间,可以精触到纳秒!
我用它来观察,一个表格的数据进行排序所花的时间!
程序如下:
procedure TForm1.ToolButton2Click(Sender: TObject);
var maxnum,i,j,eee:integer;
tempstr:string;
ddd:double;
const b:boolean=false;
begin
ddd:=gettime;
eee:=2;
case eee of
1:begin
for i:=1 to stringgrid1.RowCount-2 do
for j:=1 to stringgrid1.Rowcount-2 do
begin //冒泡算法,还可以用插入排序法。
if (strtoint(stringgrid1.cells[2,j])<
strtoint(stringgrid1.cells[2,j+1]))xor b then
begin
tempstr:=stringgrid1.cells[2,j];
stringgrid1.cells[2,j]:=stringgrid1.cells[2,j+1];
stringgrid1.cells[2,j+1]:=tempstr;
tempstr:=stringgrid1.cells[1,j];
stringgrid1.cells[1,j]:=stringgrid1.cells[1,j+1];
stringgrid1.cells[1,j+1]:=tempstr;
end;
end;
tempstr:='冒泡';
end;
2:begin
for i:=2 to stringgrid1.RowCount -1 do
for j:=i downto 2 do
begin
if (strtoint(stringgrid1.Cells[2,j])
>strtoint(stringgrid1.Cells[2,j-1]))xor b
then
begin
tempstr:=stringgrid1.cells[2,j];
stringgrid1.cells[2,j]:=stringgrid1.cells[2,j-1];
stringgrid1.cells[2,j-1]:=tempstr;
tempstr:=stringgrid1.cells[1,j];
stringgrid1.cells[1,j]:=stringgrid1.cells[1,j-1];
stringgrid1.cells[1,j-1]:=tempstr;
end
else
break;
end;
tempstr:='插入';
end;
end;
b:=not b;
ddd:=gettime-ddd;
caption:='耗时 '+floattostr(ddd)+'毫秒';
toolbar1.Buttons[1].Caption :=tempstr+'排序';
end;
这只是一份薄礼啦!请问:可爱的girl,如果一个中专生,他连中专毕业证书
都给弄丢了,那他能不能考研呢?哪怕是一个毕业证书!