```java
import java.util.Scanner;
public class CardSwap {
public static void main(String[] args) {
// 假设左手中的纸牌是10,右手中的纸牌是8
int left = 10;
int right = 8;
// 输出互换前的手中的纸牌
System.out.println("输出互换前的手中的纸牌:");
System.out.println("左手中的纸牌:" + left);
System.out.println("右手中的纸牌:" + right);
// 交换手牌
int temp = left;
left = right;
right = temp;
// 输出互换后的手中的纸牌
System.out.println("输出互换后的手中的纸牌:");
System.out.println("左手中的纸牌:" + left);
System.out.println("右手中的纸牌:" + right);
}
}
```
这个程序首先定义了两个变量`left`和`right`,分别表示左手和右手中的纸牌。然后,程序使用一个临时变量`temp`来交换这两个变量的值。最后,程序输出互换前后的手牌。
运行这个程序,你会看到以下输出:
```
输出互换前的手中的纸牌:
左手中的纸牌:10
右手中的纸牌:8
输出互换后的手中的纸牌:
左手中的纸牌:8
右手中的纸牌:10
```
这个程序展示了如何通过使用一个临时变量来交换两个变量的值。这种方法简单且易于理解,适用于大多数编程语言。