void BubbleSort( char* str, int strLen )
{
int temp = 0;
bool exchange = false;
for( int i = strLen - 1; i > 0; i-- )
{
exchange = false;
for( int m = 0; m <= i - 1; m++ )
{
if( str[m] > str[m + 1] )
{
temp = str[m + 1];
str[m + 1] = str[m];
str[m] = temp;
exchange = true;
}
}
if( !exchange )
return;
}
}
void BubbleSort( char* str, int strLen )
{
int temp = 0;
for( int i = strLen - 1; i >= 0; i-- )
{
for( int m = 0; m < i; m++ )
{
if( str[i] < str[m] )
{
temp = str[i];
str[i] = str[m];
str[m] = temp;
}
}
}
}
posted on 2010-10-10 14:04
大喜头 阅读(81)
评论(0) 编辑 收藏 引用 所属分类:
Default Category