一、 java运算
通过异或运算符实现两个变量的互换
import java.util.Scanner;public class ExchangeValueDemo
{public static void main(String[] args){try (Scanner scan = new Scanner(System.in)) {System.out.println("请输入A的值:");long A =scan.nextLong();//接收第一个变量值System.out.println("请输入变量B的值:");long B = scan.nextLong();//接收第二个变量System.out.println("A="+A+"\tB="+B);System.out.println("\t执行变量互换...\t");A=A^B;B=B^A;A=A^B;System.out.println("A="+A+"\tB="+B);}}
}