#include <cstring>
using namespace std;
void Bubblesort( char key[MaxRecord][MaxStr],
char rrn[MaxRecord], int number ) {
int temp;
char buffer[MaxStr];
for ( int i = 0; i < number-1; i++ )
for ( int j = 0; j < number-1-i; j++ )
if ( strcmp( key[j+1], key[j] ) < 0 ) {
/* compare the two neighbors */
strcpy( buffer, key[j] );
temp = rrn[j];
/* swap key[j] and key[j+1] */
strcpy( key[j], key[j+1] );
rrn[j] = rrn[j+1];
strcpy( key[j+1], buffer );
rrn[j+1] = temp;
}
}
|
|
|
|