代码如下,结果输入了之后完全没有输出,完全不清楚什么状况,求解!!!
#include
#include
#include
#include
float x,y,z;
float InvSqrt(float x)
{
float xhalf = 0.5f*x;
int i = (int)&x;
i = 0x5f3759df - (i >> 1);
x = (float)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
float count_1()
{
clock_t s1 = clock();//开始时间
float i = 1 / sqrt(x);
clock_t e1 = clock();//开始时间
printf("%.2f s\n", ((float)e1 - s1) / CLOCKS_PER_SEC);
return 0;
}
float count_2()
{
clock_t s2 = clock();//开始时间
float i = InvSqrt(x);
clock_t e2 = clock();//开始时间
y = s2 - e2;
printf("%.2f s\n", ((float)e2 - s2) / CLOCKS_PER_SEC);
return 0;
}
void main() {
printf("请输入一个值");
scanf_s("%f", &x);
float count_1();
float count_2();
system("pause");
}