[技巧]不使用額外變數做兩數交換

5 views
Skip to first unread message

cpyi

unread,
Apr 7, 2013, 8:02:50 AM4/7/13
to code_fellow...@googlegroups.com
兩數交換一般要用一個中繼變數tmp,最近看到一個寫法,可以不要用中繼變數。
a = a+b-(a=b);
這只是酷炫的技巧,別人看不懂,效率也不會提高,僅供參考。
Reply all
Reply to author
Forward
0 new messages