选择排序C++一个元素的错误输出?

选择排序C++一个元素的错误输出?,c++,sorting,selection-sort,C++,Sorting,Selection Sort,对于以下插入排序的实现,当我使用随机函数生成任意输入时,它给出了错误的输出,因为有一个元素在图片中被错误地突出显示。我努力想弄明白这是个错误,但想不出来。我的代码有什么问题 包括 包括 使用名称空间std; 样板 无效exchItem&A、项目和B { 项目t=A; A=B; B=t; } 样板 作废selectionItem列表[],int last { 项目数据; int最小,当前,walker; forcurrent=0;Current这听起来是学习使用调试器的绝佳机会;current@G

对于以下插入排序的实现,当我使用随机函数生成任意输入时,它给出了错误的输出,因为有一个元素在图片中被错误地突出显示。我努力想弄明白这是个错误,但想不出来。我的代码有什么问题

包括 包括 使用名称空间std; 样板 无效exchItem&A、项目和B { 项目t=A; A=B; B=t; } 样板 作废selectionItem列表[],int last { 项目数据; int最小,当前,walker;
forcurrent=0;Current这听起来是学习使用调试器的绝佳机会;current@Galik仍然给出错误的输出
smallest = current;
for(walker=current+1;walker<=last;walker++)
{
    if(list[walker] < list[smallest])
        smallest = walker;

    //smallest selected, exhange with the current
    exch(list[smallest],list[current]);
}
smallest = current;
for(walker=current+1;walker<=last;walker++)
{
    if(list[walker] < list[smallest])
        smallest = walker;
}
//smallest selected, exhange with the current
exch(list[smallest],list[current]);