0

Hi Dears!

I am a Beginner, Please Help Me.

If you Can Help me to find out how to sort a 2d arrays of characters with recursive bubble sort algorithm.

I have got something but it doesn't work.

what is my mistake?

I Did codes below So far, but it isn't completed and has some errors. it is my primary Idea. check it and learn me:

```
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#define number 3
#define length 3
static char student[number][length];
int i,j,k,NF_Length=15,n;
bool done;
void BubbleSort(void);
bool BubbleUp(int);
void main(){
for(i=0;i<number;i++)
for(j=0;j<length;j++)
cin>>student[i][j];
BubbleSort();
for(i=0;i<number;i++)
for(j=0;j<length;j++)
cout<<student[i][j];
getchar();
}
void BubbleSort(void){
if (number < 2) // array must be sorted
return;
done = BubbleUp(number);
if (!done){ // then bubblesort the rest
--number;
BubbleSort();
}
}
bool BubbleUp(int n){
char Temp[35];
done = true; // until we know better
for (k = 0; k < NF_Length - 1; k++){
if (strcmp(student[n][k],student[n][k+1])>0)
{
done = false; // because we are making a swap
//Now Swapping
strcpy(Temp,student[n]);
strcpy(student[n],student[n+1]);
strcpy(student[n+1],Temp);
}
}
return done;
}
```