|
I am trying to do a lottery with 6 numbers I have everything working but I wnat to sort the numbers like a standard lotto ticket. Where would the sort function go? Check my code and any help is greatly appreciated. code: #include <stdio.h> #include <stdlib.h> #include<time.h> #define SIZE 6
void printArray(int a[], int s); void fillArray(int a[], int s);
int main() { srand(time(NULL));
int array[] = {0,0,0,0,0,0};
fillArray(array, SIZE); printArray(array, SIZE);
printf("\n\nEND PROGRAM\n"); system("PAUSE"); return 0; }
void fillArray(int a[], int s) { for(int x=0; x<s; x++) { a[x] = (int) (rand()%53+1);
for(int y=0; y<x; y++) { if(a[y] == a[x]) { a[x] = (int) (rand()%53+1); x=-1; } } } }
void printArray(int a[], int s) {
printf("\nPrinting the array\n"); for(int x=0; x<s; x++) {
printf("%d ", a[x]);
} printf("\n"); }
|