Question: Consider the following C + + program: #include #include #include using namespace std; void bubble ( int , char * [ ] ) ; void
Consider the following C program:
#include
#include
#include
using namespace std;
void bubbleint char;
void swapchar int, int;
int main
int size ;
int count;
char arraysize;
char str "this is the ten token sentence that should be sorted";
char tokenptr;
tokenptr strtokstr;
count ;
while tokenptr nullptr
arraycount tokenptr;
tokenptr strtoknullptr;
count;
for int i ; i ; i
cout arrayi endl;
bubblesize array;
cout "sorted list:" endl;
for int i ; i ; i
cout setw arrayi length is strlenarrayi;
cout endl;
return ;
void bubbleint size, char arr
for int j ; j size; j
for int count ; count size ; count
if strcmparrcount arrcount
CSCE Lab
swaparr count, count ;
return;
void swapchar ptr int first, int second
char temp;
temp ptrfirst;
ptrfirst ptrsecond;
ptrsecond temp;
return;
This program uses a bubble sort to sort a list of ten words. The complexity of the
program is to break the character string into "tokens". Since this program uses the
strtok function to do this, you may want to search wwwcplusplus.com or look
at the man page for strtok eg man strtok Please note that you will not be
tested over this function, but it may help you as you proceed in your academic and
professional career
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
