主页
C 语言
C stdlib rand() 函数
demo_ref_stdlib_rand
运行 ❯
×
更改方向
保存代码
更改主题
#include
#include
#include
int main() { // Initialize the randomizer using the current timestamp as a seed // (The time() function is provided by the
header file) srand(time(NULL)); // Generate random numbers for(int i = 0; i < 10; i++) { int num = rand() % 100 + 1; printf("%d ", num); } return 0; }
9 27 7 11 80 37 92 32 60 41