您的位置:首页 > 其它

(LintCode) No 5: Swap Two Integers in Array

2018-03-16 21:20 330 查看
题目描述:交换一个数列中两个数字的位置。
代码如下:public class Solution {
/**
* @param A: An integer array
* @param index1: the first index
* @param index2: the second index
* @return: nothing
*/
public void swapIntegers(int[] A, int index1, int index2) {
int n;
n = A[index1];
A[index1] = A[index2];
A[index2] = n;// write your code here
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: