小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

106.產(chǎn)生隨機數(shù)

 C語言與CPP編程 2022-05-03 發(fā)布于安徽
/* 在BC31下編譯 */
/* compile under Borland C++ 3.1 */
#include <stdio.h>
#include <sys\timeb.h>
#define Alpha 3.90

double initvalue();

double random(void)/*返回一個(0,1)之間的隨機數(shù)*/
{
    static double f=-1.0;
    double initvlaue();
    if(f==-1.0) f=initvalue();
    else f=Alpha*f*(1.0-f);
    return f;
}

double initvalue()/*返回隨機數(shù)序列初值*/
{
    double f0;
    struct timeb *pr;
    for(;;){
		ftime(pr);
		f0=pr->millitm*0.9876543*0.001;
		if(f0<0.001) continue;
		break;
    }
    return f0;
}

void main()
{
	double test;
	int i;
	clrscr();
	puts("This is a random number generator.");
	puts("\n The random number are: ");
	for ( i = 0; i < 3; i++ )
	{
		test = random();
		printf ( " >> rand%d:%f\n", i, test );
	}
	puts("\n Press any key to quit...");
	getch();
}

    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多