for 后面 int i
程序返回值不是0,运行出错。可能minpos和maxpos初始化有误,导致互换的时候越界了
你这里不用用 temp ,直接 a[maxpos] = min;a[minipos] = max;