Question: #include #include #include #include #define LIMIT 50 #define RAND_RANGE 100 int source[LIMIT]; // array to hold input data values int dest[LIMIT]; // array to hold
| #include | |
| #include | |
| #include | |
| #include | |
| #define LIMIT 50 | |
| #define RAND_RANGE 100 | |
| int source[LIMIT]; // array to hold input data values | |
| int dest[LIMIT]; // array to hold sorted data values | |
| // use "dest" only if you are using two arrays | |
| bool valid[LIMIT]; // array that indicates which input values are valid | |
| // use "valid" only if you are using two arrays | |
| int i; // loop variable | |
| int j; // loop variable | |
| int smallest; // current smallest element | |
| int main(){ | |
| //seed random numbers | |
| srand((unsigned)time(NULL)); | |
| //initialize valid array - at begining the full array is valid | |
| for (i=0; i | |
| valid[i] = true; | |
| } | |
| //initialize source array with random number from 0..RAND_RANGE | |
| for (i=0; i | |
| source[i] = rand() % RAND_RANGE; | |
| } | |
| //print out source array in rows of 20 elments | |
| printf("Source array: "); | |
| for (i=0; i < ((LIMIT/20)+1); i++) { | |
| for (j=0; j<20; j++) { | |
| if (i*20+j < LIMIT) { | |
| printf("%.2d ",source[i*20+j]); | |
| } | |
| } | |
| printf(" "); | |
| } | |
| printf(" "); | |
| //selection sort | |
| for (i=0; i | |
| // INSERT YOUR CODE HERE | |
| } | |
| //print out sorted array in rows of 10 | |
| // INSERT YOUR CODE HERE | |
| return 0; | |
| } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
