永发信息网

c语言srand 函数 限定范围1~6 怎么输入谢谢了,大神帮忙啊

答案:2  悬赏:10  手机版
解决时间 2021-03-17 06:03
  • 提问者网友:不要迷恋哥
  • 2021-03-16 13:53
c语言srand 函数 限定范围1~6 怎么输入谢谢了,大神帮忙啊
最佳答案
  • 五星知识达人网友:患得患失的劫
  • 2021-03-16 14:32
#include #include void main() { int a[6]; int i; unsigned seed; printf("please enter seed:\n"); scanf("%u",&seed); srand(seed); printf("系统自动生成随机数:\n"); for(i=0;i<6;i++) { a[i]=rand()%89+10; printf("%d ",a[i]); }
全部回答
  • 1楼网友:第四晚心情
  • 2021-03-16 15:14
一:scanf("%3f%3f%3f",&a,&b,&c); 这里要求输入数据必须为三位数,最好改成: scanf("%f%f%f",&a,&b,&c); 去掉限定 二: void tonggen(float a,float b,float k) //float a,b,k; 如果这样定义,则上一行的函数定义应该写成:void tonggen( a, b, k) 二者不能同存 { float x; x=(-b)/(2*a); //这里应该为2*a printf("二次函数为同根为x=%3f",x); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯