本例子中,因为产品中无法正确采取到功率因素,在这里,伪造一个功率因素,考虑到其功率最大概率在 0.97.0.96.0.99之间。
#include <stdio.h>
#include <time.h>
int main(int argc, char* argv[])
{
float number;
int i=0;
srand( (unsigned)time( NULL ) );
// for(i=0;i<100000;i++)
while(1)
{
number=(float)((rand()%3+97))/100;
printf("%d\n",rand()%3+97);
printf("%.3f\n",number);
usleep(1000*500);
}
return 0;
}
~
原文:http://www.cnblogs.com/hongzhunzhun/p/5097836.html