# C语言不设置临时变量交换x和y的值（方法）

```c
#include <stdio.h>
//异或
int main() {
    int x = 10, y = 20;
    x = x ^ y;
    y = x ^ y;
    x = x ^ y;
    printf("x的值为：%d，y的值为：%d\n", x, y);
    return 0;
}

```

```c
#include <stdio.h>

int main() {
    int x = 10, y = 20;
    x = x + y;
    y = x - y;
    x = x - y;
    printf("x的值为：%d，y的值为：%d\n", x, y);
    return 0;
}

```

