ActionScript 之 九九乘法表

 //定义一个字符串来存放数据 

var theText:String = "";
//测试赋值
//tf.text = theText;

var theNum:Array = ["1","2","3","4","5","6","7","8","9","10"];

for(var i:uint = 1; i < 10; i++){
for(var j:uint =1; j <= i; j++){
var _result:String;
if(i * j < 10){
_result = "=" + theNum[i * j -1];
}else if(i * j == 10){
_result = "=1";
}else if(i * j < 20){
_result = "=1" + theNum[i * j % 10 - 1];
}else if(i * j % 10 == 0){
_result = "=" + theNum[Math.floor(i * j / 10) - 1] + "0";
}else{
_result = "=" + theNum[Math.floor(i * j / 10) - 1] + theNum[i * j % 10 - 1];
}
theText += theNum[j -1] + "*" + theNum[i -1] + _result + "\t";
}
theText += "\n";
}

//tf 是一个动太文本框,用来显示数据
tf.text = theText; 

你可能感兴趣的:(表)