注册 登录
编程论坛 C语言论坛

怎么错了啊???

是刘啊 发布于 2023-06-28 19:06, 813 次点击
代码:
#include <stdio.h>
#include <time.h>
int main(void){
     char v[]=("1 2 3 4 5 6 7 8 9 0");
     unsigned seed=time(NULL);
     srand(seed);
     printf("%c",v[rand()%10]);
}
3 回复
#2
apull2023-06-28 20:47
程序代码:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
     char v[]="1234567890";
     unsigned seed=time(NULL);
     srand(seed);
     printf("%c",v[rand()%10]);
}

#3
s962812023-06-29 12:39
srand函數包含在stdlib.h庫中
你忘了include stdlib.h了
#4
是刘啊2023-06-29 21:10
谢谢各位
1