; 计算字符出现频率。
Local $sResult, $sText = InputBox("", "字符出现频率"), $sVal
For $i = 1 To StringLen($sText)
$sVal = StringMid($sText, $i, 1)
Assign(".." & $sVal, Eval(".." & $sVal) + 1)
$sResult = StringReplace($sResult, ".." & $sVal & @TAB & (Eval(".." & $sVal) - 1) & @CRLF, "") & _
".." & $sVal & @TAB & Eval(".." & $sVal) & @CRLF
Next
Msgbox(0, '', $sResult)
; 1 - 1000中的素数。
Local $sResult = ""
For $i = 3 To 1000 Step 2
$iX = 0
For $j = 3 To 37 Step 2
If 1 / Mod($i, $j) = "1.#INF" Then $iX += 1
Next
If $iX < 2 Then $sResult &= $i & ", "
Next
Msgbox(0, '', "2, " & StringTrimRight($sResult, 2))
; 随机矩阵
Local $iMax, $sResult = "", $iRandom
For $i = 1 To 20
$iRandom = Random(200, 400, 1)
$sResult &= $iRandom & ", "
If Mod($i, 4) = 0 Then $sResult = StringTrimRight($sResult, 2) & @LF
If $iRandom > $iMax Then $iMax = $iRandom
Next
Msgbox(0, $iMax, $sResult)
; 回文数
Do
$iFlags = 0
$sNum = Number(InputBox("", "判断回文数"))
$iLength = StringLen($sNum)
If $iLength < 2 OR Mod($iLength, 2) = 0 Then ContinueLoop
For $i = 1 To Int($iLength / 2)
If StringMid($sNum, $i, 1) <> StringMid($sNum, $iLength - $i + 1, 1) Then $iFlags = 1
Next
If $iFlags = 1 Then ContinueLoop Msgbox(0, "", "NO")
ExitLoop Msgbox(0, '', "YES")
Until 0
; 水仙花数
Do
Local $iX = Number(InputBox("", "水仙花数")), $iY = 0
If StringLen($iX) <> 3 Then ContinueLoop
For $i = 1 To 3
$iY += Number(StringMid($iX, $i, 1)) ^ 3
Next
If $iY = $iX Then ExitLoop Msgbox(0, $iY, "YES")
Msgbox(0, $iY, "NO")
Until 0
; 阶乘
Local $iX = 7, $iY = 1
For $i = 1 To $iX
$iY *= $i
Next
Msgbox(0, '', $iY)