C语言 不使用临时变量交换两个数

来源:互联网 发布:高光谱遥感数据集 编辑:程序博客网 时间:2024/05/21 06:49

利用两个数的异或运算实现交换

#include <stdio.h>int main(){    int a,b;    scanf("%d%d",&a,&b);    int c;    c=a^b;    a=a^c;    b=b^c;    printf("%d %d",a,b);    return 0;}



0 0
原创粉丝点击