在C兰德功能 [英] Rand function in c

查看:165
本文介绍了在C兰德功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  用于C'S兰特哪些常见的算法()?

是怎样的C库中定义rand函数。什么是rand函数的时间复杂度。如果有人可以提供rand函数源$ C ​​$ C(我不需要它的实现,但源$ C ​​$ C)这将是巨大的。感谢名单

How is the rand function defined inside the c library. What is the time complexity of rand function. If someone can provide the source code for rand function(I don't need its implementation but the source code) it would be great. Thanx

推荐答案

这是 0 的(1)的复杂性,也没有输入,它返回1 INT

It's O(1) complexity, there is no input and it returns one int.

http://www.jbox.dk/sanos/source /lib/stdlib.c.html :

int rand()
{
  return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}

这篇关于在C兰德功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆