当前位置:首页 > 编程技术 > 正文

c语言如何获取时间种子

c语言如何获取时间种子

```cincludeincludeincludeint main( { // 获取当前时间作为时间种子 srand((unsigned int time(NULL ...

```c

include

include

include

int main() {

// 获取当前时间作为时间种子

srand((unsigned int)time(NULL));

int randomNumber = rand() % 100;

printf("Random number: %dn", randomNumber);

return 0;

最新文章