📜  Java 程序使用按位异或运算符交换两个数字 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:24.015000             🧑  作者: Mango

代码示例1
import java.util.Scanner;public class Main {public static void main(String args[]){int m, n;Scanner s = new Scanner(System.in);System.out.print("Enter the first number");m = s.nextInt();System.out.print("Enter the second number");n = s.nextInt();m = m ^ n;n = m ^ n;m = m ^ n;System.out.println("After Swapping the number");System.out.println("First number:"+m);System.out.println("Second number:"+n);}}