sortarray[(lowIndex + highIndex) / 2]关于数组,如果中括号里面的数是小数该怎么办

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/16 22:50:55
sortarray[(lowIndex + highIndex) / 2]关于数组,如果中括号里面的数是小数该怎么办

sortarray[(lowIndex + highIndex) / 2]关于数组,如果中括号里面的数是小数该怎么办
sortarray[(lowIndex + highIndex) / 2]关于数组,如果中括号里面的数是小数该怎么办

sortarray[(lowIndex + highIndex) / 2]关于数组,如果中括号里面的数是小数该怎么办
可以在计算后将结果强转为整数,因不清楚你使用的语言,无法给出实例代码,类似 sortarray[int((lowindex+highindex)/2)],但理论上你在设计时就应该考虑此方式是否恰当,多思考下为什么一定是(lowindex+highindex)/2