float random = rand();
printf("\n");
for(int i=0; i<5; i++){//find node is weight close
c[0]=0;
c[i+1]=weight
;
}
//float random;
puts("input number");
scanf("%f",&random);
random=1/random;
for(int i=0; i<5; i++){
if(random>c && random<=c[i+1]){
node[n]=i;////becase array begin 0
n++;/////////////////////////////////////
}
}
printf("\n");
printf("\n\trandom is %f\n",random);
for(int i=0; i<n; i++){
printf("\t %d ",node+1);////becase array begin 0
}
printf("\n-------------------------------------------");
printf("\n");
return node[n]; //sent back nodde[] array size n
}
นี่เป็นส่วนหนึ่งในโปรแกรมครับ
คือผมอยากจะ random ค่าระหว่าง 0.00-1.00 ครับจากเดิมที่ code นี้มันจะรับค่าจาก keybrood มาครับ ผมต้องแก้ส่วนไหนครับช่วยที่ครับ
