May i know how to write a lucky pick program in dos mode.
got a group of number 1 to 52. got 6 group to select it. and each time when the group get the number it will obliterate it from the number group.
Printable View
May i know how to write a lucky pick program in dos mode.
got a group of number 1 to 52. got 6 group to select it. and each time when the group get the number it will obliterate it from the number group.
What have you tried?
actually i'm newbie i dun know where should i start.
That's a shame.
Do you know how to pick numbers randomly?
Do you know how to check whether one number is the same as another number?
here's one that uses the "Fischer-Yates shuffle":
Code:#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int x, ray[52], i, y, tmp;
for (i=0;i<52;i++) ray[i]=i;
srand(time(0));
for (i=51;i>=0;i--) {
x=RAND_MAX/(i+1);
y=rand(); y/=x;
if (y==i) continue;
tmp=ray[i];
ray[i]=ray[y];
ray[y]=tmp;
}
for (i=0;i<6;i++) printf("%d\n",ray[i]);
return 0;
}
i want to make it the lucky pick number's row that i want. and how to sort the number ascending