עזרה בבקשה, אני מחפש כיוון
לפני שבועיים בערך רשמתי שיש לי בעיה ועדין אני מחפש פתרון לבעיה והיא כך: אני לא מצליח למספר את הערכים של המערך ביחס למספר הקרוב לממוצע. הייתי מעוניין לקבל רעיונות או עזרה בפיתרון הבעיה שלי, אשמח עם תוכלו לעזור לי. אני כרגע מצרף את הקוד שעליו אני עובד בתרגיל:
לפני שבועיים בערך רשמתי שיש לי בעיה ועדין אני מחפש פתרון לבעיה והיא כך: אני לא מצליח למספר את הערכים של המערך ביחס למספר הקרוב לממוצע. הייתי מעוניין לקבל רעיונות או עזרה בפיתרון הבעיה שלי, אשמח עם תוכלו לעזור לי. אני כרגע מצרף את הקוד שעליו אני עובד בתרגיל:
<% dim total dim counter dim avg dim dis dim minDis SN = 10 'offerid=2 Set conn=Server.CreateObject("ADODB.connection") Set rs=Server.CreateObject("ADODB.recordset") sql= "SELECT * " _ & "FROM Usercommerce " _ & "WHERE SaleNumber like '" & SN &"'" _ & "ORDER BY offerprice DESC, shkalim DESC, agorot DESC" conn.Open "dsn=commerce" rs.Open sql, conn total = 0 counter = 0 do while not rs.EOF total = total + rs.fields("offerprice") counter = counter + 1 rs.moveNext loop rs.movefirst dis=total avg = total/counter dis = total Response.write("avg:" & avg & ", the array:") do while not rs.EOF Response.write(rs.fields("offerprice") & " ") Response.Write "</br>" if (Abs(avg-rs.fields("offerprice")))<dis then dis = Abs(avg-rs.fields("offerprice")) minDis = rs.fields("offerprice") end if rs.movenext loop response.write("<br>minDis = " & minDis) 'c.close
אשמח לקבל רעיונות או תשובות ובכלל עזרה בנושא. בכבוד רב רוני.