Question: #include keep this format #include #include #include #define LIMIT 200 #define RAND_RANGE 95 // 95 printing characters x20-x7E char source[LIMIT]; // array to hold input
| #include | |
| keep this format | #include |
| #include | |
| #include | |
| #define LIMIT 200 | |
| #define RAND_RANGE 95 // 95 printing characters x20-x7E | |
| char source[LIMIT]; // array to hold input data values | |
| int i; | |
| int j; | |
| // return random character | |
| char randChar() { | |
| // 0 -> x20 -> ' ' | |
| // 1 -> x21 -> '!' | |
| // ,,, | |
| // 94 -> x7E -> '~' | |
| // see https://ascii.cl | |
| return ((char)((rand() % RAND_RANGE)+0x20)); | |
| } | |
| // break data array up into halves until down to single elements | |
| // then merge them | |
| void msort(char* data, int left, int right) { | |
| // please only modify this next line | |
| // ADD YOUR CODE HERE | |
| return; | |
| } | |
| int main(){ | |
| //seed random numbers | |
| srand((unsigned)time(NULL)); | |
| //initialize source array with random character | |
| for (i=0; i | |
| source[i] = randChar(); | |
| } | |
| //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("%c ",source[i*20+j]); | |
| } | |
| } | |
| printf(" "); | |
| } | |
| printf(" "); | |
| // do the sorthing | |
| msort(source, 0, LIMIT-1); | |
| //print out sorted array in rows of 10 | |
| printf("Destination array: "); | |
| for (i=0; i < ((LIMIT/10)+1); i++) { | |
| for (j=0; j<10; j++) { | |
| if (i*10+j < LIMIT) { | |
| printf("%c ",source[i*10+j]); | |
| } | |
| } | |
| printf(" "); | |
| } | |
| printf(" "); | |
| return 0; | |
| } |
Step by Step Solution
There are 3 Steps involved in it
The question is missing a detailed problem statement or task description To help I wi... View full answer
Get step-by-step solutions from verified subject matter experts
