本帖最后由 初学C 于 2017-8-8 15:15 编辑
不过还有一种方法是结果更加精确:使用寄存器变量
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
register int i = 0;
register unsigned s = GetTickCount();
loop:;
if(1000000000 - (i++)) goto loop;
printf("%ums",GetTickCount() - s);
system("@pause > nul");
return 0;
}[/mw_shl_code]
这段代码我的xp上运行结果是245ms(对不起打错了是545ms)
在我的win8上运行结果是1188ms
|