c语言在固定数中产生随机数,比如307,3805,3852,823,704这些数中产生随机数

学习 时间:2026-04-03 13:14:29 阅读:1545
c语言在固定数中产生随机数,比如307,3805,3852,823,704这些数中产生随机数

最佳回答

辛勤的画板

老实的睫毛

2026-04-03 13:14:29

#include#include#include#includeint t[5]={307,3805,3852,823,704};int main(){int test=10;srand(unsigned(time(NULL)));while(test--)printf("%d\n",t[rand()%5]);return 0;} 再问: 有错误 再答: 你是C还是C++啊?什么错误啊?

最新回答共有2条回答

  • 稳重的凉面
    回复
    2026-04-03 13:14:29

    #include#include#include#includeint t[5]={307,3805,3852,823,704};int main(){int test=10;srand(unsigned(time(NULL)));while(test--)printf("%d\n",t[rand()%5]);return 0;} 再问: 有错误 再答: 你是C还是C++啊?什么错误啊?

上一篇 已知A=(2x+1)(x-1)-x(1-3y),B=-x^2+xy-1,且3A+6B的值与x无关,求y

下一篇 清河村棉花的种植面积是24公顷,占全村耕地面积的三分之二.全村的耕地面积是多少公顷?