Some simple php algorithm programs (bubble, fast, etc.) and php algorithm programs bubble. Some simple php algorithm programs (bubble, fast, etc.), php algorithm programs bubble functionbuttle_sort ($ array) {$ lencount ($ array); if ($ len2) {return $ array;} for ($ I some simple php algorithm programs (bubble, fast, etc.), php algorithm programs bubble
Function buttle_sort ($ array) {$ len = count ($ array); if ($ len <2) {return $ array;} for ($ I = 0; $ I <$ len; $ I ++) {$ flag = false; // The swap flag should be false for ($ j = $ len-1; $ j> $ I; $ j --) {if ($ array [$ j] <$ array [$ j-1]) {$ tmp = $ array [$ j]; $ array [$ j] = $ array [$ j-1]; $ array [$ j-1] = $ tmp; $ flag = true; // exchange occurred, therefore, set the switch flag to true }}if (! $ Flag) // The return $ array algorithm is terminated in advance because the current sorting has not been exchanged ;}
To be supplemented
Bubble (bubble, fast, etc.), php algorithm program bubble function buttle_sort ($ array) {$ len = count ($ array); if ($ len 2) {return $ array ;} for ($ I =...