回复 9 楼 dreamofgod
代码可以稍微简化一下
程序代码:#include<stdio.h>
#include<windows.h>
int xxx()
{//通过GetTickCount来计时,static来保留第一次运行的时间,之后每次运行该函数时与第一次的时间对比
static DWORD x = 0;
DWORD h = GetTickCount();
if (x == 0)
{
x = GetTickCount();
return 1;
}
return ((h-x)/1000)+1;
}
int main(void)
{
printf("%d",xxx());//第一次调用xxx()
Sleep(2000);//隔两秒
printf("%d",xxx());//第二次调用xxx(),因为间隔了两秒则+2
return 0;
}

一个单片机就让我头疼不已~~~









