c语言滑屏程序,三角旋转屏 c rand 算法_c rand函数_c语言rand

bdc890b54adeb0beacd99a03c4784729.png

/* rand0.c ---产生随机数*/

/*使用ANSI C 可移植算法*/

static unsigned long int next=1; //种子

int rand0(void)

{

next=next*1103515245+123456;

return (unsigned int)(next/65536)%32768;

}

void srand0(unsigned int seed)

{

fb9083e35f1b2399f70d258092e2ee0e.png

next=seed;

}

/*r_drive0.c 测试rand0() srand0()函数*/

#include

#include

extern void srand0(unsigned int);

extern int rand0(void);

int main(void)

{

int count;

srand0((unsigned int)time(0));

for(count=0;countprintf("%d\n",rand0());

return 0;

}

/

1> 为什么rand0() 函数里面的那2个公式是可移植算法?

2> static unsigned long int next; 是unsigned long 类型的c rand 算法,为什么srand0((unsigned int )time(0))

数据要指派成unsigned int 类型推屏,而不是unsigned long 类型c rand 算法多功能一体机,难道为了增加移植性?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值