العربية  

books get the arithmetic mean

If you do not find what you're looking for, you can use more accurate words.

View more

جلب المتوسط الحسابي (Info)


يحتوي الشيفرة التالي : دالة من المستخدم ونافذة وشرط.

;Finds the average of numbers specified by a user. ;The numbers must be delimited by commas. #NoTrayIcon #include <GUIConstantsEx.au3> #include <Array.au3> #region---------------GUI----------------------- $form = GUICreate("Average Finder", 300, 100) $label = GUICtrlCreateLabel("Enter the numbers to be averaged separated by commas", 19, 0) $textbox = GUICtrlCreateInput("", 20, 20, 220) $label1 = GUICtrlCreateLabel("=", 245, 20, 30, 20) $ansLabel = GUICtrlCreateLabel("", 255, 20, 50, 20) $button = GUICtrlCreateButton("Find Average", 100, 40) GUISetState(@SW_SHOW) #endregion---------------END GUI----------------------- While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $button Then If _findAvg(GUICtrlRead($textbox)) = "malform1" Then GUICtrlSetData($ansLabel,"Error") Else GUICtrlSetData($ansLabel, _findAvg(GUICtrlRead($textbox))) EndIf EndIf WEnd Func _findAvg($nums) Local $sData Local $ans ;Clean up input format-----------------> $chk = StringRight($nums, 5) If $chk = "," Then $nums = StringTrimRight($nums, 1) If StringInStr($nums, ",") < 1 Then Return ("malform1") EndIf ;----------------------------------> $sData = StringSplit($nums, ",") $ans = 0 For $i = 1 To $sData[0] $ans += $sData[$i] Next $ans = $ans / $sData[0] Return ($ans) EndFunc ;==>_findAvg

Source: wikipedia.org