数组的运算怎样写成自定义函数
怎样把数组内容+6这个运算方式写成自定义函数呢?;输出数组列表Dim $array = [,,],$s,$addarray
For $a = 0 to 2
For $b = 0 to 2
$array[$a][$b] = $array[$a][$b] +6
;MsgBox(0,"偱环输出","$array[" &$a & "][" &$b& "] = " &$s)
Next
$s=$s&@crlf
Next
MsgBox(0,"数组","数组每项+6成功")
;数组列表
For $a = 0 to 2
For $b = 0 to 2
$s = $s&" "&$array[$a][$b]
;MsgBox(0,"偱环输出","$array[" &$a & "][" &$b& "] = " &$s)
Next
$s=$s&@crlf
Next
MsgBox(0,"偱环输出",$s)
[ 本帖最后由 xiaolt2008 于 2008-12-24 16:12 编辑 ] #include 'array.au3'
Dim $array = [,,], $s, $addarray
_ArrayDisplay($array, "已定义的数组:")
$new=_array_addnum($array,6)
_ArrayDisplay($new,'数组每项加6,形成的新数组')
Func _array_addnum($_array, $_num)
If Not IsArray($_array) Then Return
For $i = 0 To UBound($_array, 1) - 1
For $j = 0 To UBound($_array, 2) - 1
$_array[$i][$j] += $_num
Next
Next
Return $_array
EndFunc ;==>_array_add
有什么用??
回复 2# pcbar 的帖子
谢谢,我是想操作数组,比如一个闹钟,添加几个不同的时间,那把时间放到数组里面去会方便点。你有好的方法吗? 谢谢楼主提供
页:
[1]