public class ChangeTwoNumber{ public static void main(String[] args){ changeTwoNumber(1,2); } /** * 交换两个int数的值 */ static void changeTwoNumber(int a, int b){ System.out.println("what user input is: a = " + a + ", b = " + b); a = a ^ b; b = a ^ b; a = a ^ b; System.out.println("what the program output is: a = " + a + ", b = " + b); } }
交换两个数的值,且不引入第三个变量的实现
最新推荐文章于 2023-02-25 12:24:39 发布