C语言交换两个数的值

来源:互联网 发布:电话薄软件 编辑:程序博客网 时间:2024/04/30 08:35

#include <stdio.h>
int main()
{
  int a = 10;
  int b = 20;
  int temp = 0;
  printf("a=%d b=%d\n",a,b);
  temp=a;
  a=b;
  b=temp;
  printf("a=%d b=%d\n",a,b);
  return 0;
}


#include <stdio.h>

int main()
{
  int a = 10;
  int b = 20;
  printf("a=%d b=%d\n",a,b);
  a=a^b;
  b=a^b;
  a=a^b;
  printf("a=%d b=%d\n",a,b);
  return 0;
}
0 0
原创粉丝点击