2011年10月11日

          C下不用中間變量交換兩個變量值

           1 #include<stdio.h>
           2 
           3 void inplace_swap(int *int *);
           4 void main(){
           5     int a = 10;
           6     int b = 20;
           7     
           8     inplace_swap(&a, &b);
           9     system("pause");
          10 }
          11 
          12 void inplace_swap(int *x, int *y){
          13     *= *^ *y;
          14     printf("%d, %d\n"*x, *y);
          15     
          16     *= *^ *y;
          17     printf("%d, %d\n"*x, *y);
          18     
          19     *= *^ *y;    
          20     printf("%d, %d\n"*x, *y);
          21 }

          posted @ 2011-10-11 13:19 灰色客棧 閱讀(229) | 評論 (0)編輯 收藏

          <2011年10月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 康平县| 顺平县| 大名县| 临邑县| 鄂伦春自治旗| 康保县| 察雅县| 新昌县| 资源县| 额济纳旗| 望谟县| 环江| 新民市| 西和县| 治多县| 会泽县| 平乐县| 北票市| 扶余县| 紫云| 团风县| 广元市| 衡阳县| 宁波市| 九龙城区| 华亭县| 永丰县| 冷水江市| 枞阳县| 常德市| 疏勒县| 博野县| 富民县| 琼中| 阿城市| 叙永县| 靖远县| 芜湖县| 上犹县| 凤阳县| 灵寿县|