这是我的代码:
void bubbleSortInventory(article inventory[], int noOfArticles){
int newn;
int check = 0;
while(check != 0){
newn = 0;
for(int i = 1; i <= noOfArticles-1;i++){
if(inventory[i-1].id>inventory[i].id){
swap(&inventory[i-1].id,&inventory[i].id);
newn = i;
}
}//end for-loop
check = newn;
}
}
和交换功能:
void swap(int *number1, int *number2){
int temporaryHolder;
temporaryHolder = *number1;
*number1 = *number2;
*number2 = temporaryHolder;
}
现在问题来了,当我打印出数组库存时,它似乎没有被排序
有谁知道我做错了什么?
已解决,谢谢