Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions