c - 生成两个限制之间的随机数

标签 c

有没有一种方法可以在不使用 sran 和 rand 函数的情况下生成两个限制之间的数字
我有一个 while (1) ( super 循环),它每 10 毫秒调用一个函数。在函数中,使用 for 循环来创建延迟,但是,每次访问该函数时,延迟都应该不同,但在两个限制之间,8 和 2 毫秒,for(x=0;x<random_number;x++)

最佳答案

尝试以下希望这能回答您的问题。

#include<stdio.h>
#include <stdlib.h>
int main()
{
    int iMaxRand =100,ii=0 ;
    while( ii < 100)
    {
         printf("Random Number is:%d\n", rand() % iMaxRand);
         ii++;
     }
     printf("\n");
}

关于c - 生成两个限制之间的随机数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9728816/

相关文章:

c - "cannot open source file"- 包含 header ,Visual Studio 2015

C 指针在传递给函数后未设置

c - 为什么**pointer2可以改变变量a?

c++ - 如何在gtkrc中捕获GTK焦点状态?

c - 获取 write() 系统调用以写入文件

c - Extended Inline Assembly GCC-编译时表达式错误后错误的寄存器名称和垃圾 'done'

C GPA 平均总分

c - Valgrind 报告

c++ - Linux gdb 'examine' 行为

c - 如何将标准输出重定向到一个文件,然后恢复标准输出?