当前位置:主页>仓库管理软件> 列表

这样一个函数如何转化为delphi的函数? 找零售软件

仓库管理软件版1楼: static
int compare(const void* a, const void* b)

{ const double term1 = *(*(double**)a);
const double term2 = *(*(double**)b);
if (term1 < term2) return -1;
if (term1 > term2) return +1;
return 0;
}

2楼: function compare(a,b:Pointer):integer;
var
term1,term2:double;
begin
term1:=PDouble(a)^;
term2:=PDouble(b)^;
if term1 Result:=-1
else
if term1>term2 then
Result:=1
else
Result:=0
end; 如零售软件

3楼: Double 是要使用 CompareValue比较的。
Uses
Math;
function compare(a,b:Pointer):integer;
begin
Result := CompareValue(PDouble(a)^, PDouble(b)^);
end;

4楼: 谢谢,两位了。

5楼: 散分!散分!

6楼: 多人接受答案了。