码迷,mamicode.com
首页 > 其他好文 > 详细

交换两个变量的值,不得借助额外的存储空间,还有哪些方法?

时间:2014-11-20 11:43:51      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:io   sp   div   bs   amp   c   nbsp   方法   return   

   #include <stdio.h>

     int main()

{

      int a,b;

      printf("请输入两个数:\n");

      scanf("%d %d",&a,&b);

     a^=b;

     b^=a;

     a^=b;

     printf("%d %d",a,b);

     return 0;

}

 

 

 

 

交换两个变量的值,不得借助额外的存储空间,还有哪些方法?

标签:io   sp   div   bs   amp   c   nbsp   方法   return   

原文地址:http://www.cnblogs.com/jjl591362424/p/4110005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!