シェルソート
http://www40.atwiki.jp/spellbound/pages/457.html
♥0 |
Line 31 |
Modified 2011-09-13 13:39:33 |
MIT License
archived:2017-03-20 05:48:07
ActionScript3 source code
/**
* Copyright toilet7 ( http://wonderfl.net/user/toilet7 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uNI3
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var data:Array = [8, 4, 3, 7, 6];
for (var h:int = data.length / 2; h > 0; h /= 2)
{
for (var i:int = h; i < data.length; i++)
{
var temp:int = data[i];
for (var j:int = i - h; j >= 0 && data[j] > temp; j -= h)
{
data[j + h] = data[j];
}
data[j + h] = temp;
}
}
showResult(data);
}
private function showResult(...result:*):void
{
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat("arial", 19);
tf.text = result.toString();
tf.autoSize = "left";
addChild(tf);
}
}
}