冒泡算法講解

我發現,不少人寫的所謂冒泡算法代碼,實際上是錯的,這裏給一份正確的代碼,並講解正確的冒泡代碼的特徵 程序代碼: #include <stdio.h> #include <stdlib.h> #include <time.h> // 這個宏,定義交換兩個數a,b,其中t是交換臨時變量 #define SWAP(a, b) do {int t = a; a = b; b = t; } while(0)
相關文章
相關標籤/搜索