Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define RANGE 10
- #define BALLS 6
- int main()
- {
- int numbers[RANGE];
- int c, ball;
- puts("L O T T O\t P I C C K E R");
- srand((unsigned)time(NULL));
- /* Initialize the array */
- for(c=0;c<RANGE;c++)
- {
- numbers[c] = 0;
- }
- printf("Press ENTER to pick this week's number:");
- getchar();
- /* draw the numbers */
- puts("\nHere they come:\n");
- for(c=0;c<BALLS;c++)
- {
- /* See if a number has been allready been drawn */
- do
- {
- ball = rand() % RANGE; /* Generate the random ball */
- }
- while(numbers[ball]); /* How is this compare made ? */
- /* Number drawn */
- numbers[ball] = 1; /* What is this for ?!? */
- printf("%2d ", ball+1); /* add 1 to ball so ball won't be zero */
- }
- printf("\n\nGood luck in the drawing!\n");
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement