Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/11/2005, 21:08
Avatar de u_goldman
u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 23 años, 3 meses
Puntos: 98
Buenas sqa, me diverti bastante con el script este, aqui te lo dejo, no esta totalmente probado, pero a lo mejor te da una idea:

Código:
<%
Function OrdenaArreglo(arreglo)
	If isArray(arreglo) Then
		Dim temp
		arrOr = arreglo
		For i = 0 to uBound(arrOr)
			For j = i + 1 to uBound(arrOr)		
				If cint(arrOr(i)) > cint(arrOr(j)) Then
					temp = arrOr(i)
					arrOr(i) = arrOr(j)
					arrOr(j) = temp
				End If
			Next
		Next
	Else
		OrdenaArreglo = Null
	End If
	OrdenaArreglo = arrOr
End Function

Function AnalizaArreglo(arr)
	Dim strUnidades
	for j = 0 to uBound(arr)
		if j = 0 then
			strUnidades = arr(j) & ","
		end if
		on error resume next
		if arr(j) <> arr(j+1) then
			strUnidades = strUnidades & arr(j+1) & ","
		end if
	next
	'response.Write strUnidades
	strUnidades = left(strUnidades, len(strUnidades) - 1)
	arrUnidades = split(strUnidades, ",")
	Dim arrCoincidencias()
	Redim arrCoincidencias(uBound(arrUnidades))
	for j = 0 to uBound(arrUnidades)
		for i = 0 to uBound(arr)
			if cint(arr(i)) = cint(arrUnidades(j)) then
				if isEmpty(arrCoincidencias(j)) then
					arrCoincidencias(j) = 0
				end if
				arrCoincidencias(j) = arrCoincidencias(j) + 1
			end if
		next
	next
	Dim mtxUnidadesCoincidencias()
	Redim mtxUnidadesCoincidencias(uBound(arrUnidades),1)
	
	for j = 0 to uBound(arrCoincidencias)
		mtxUnidadesCoincidencias(j,0) = arrUnidades(j)
		mtxUnidadesCoincidencias(j,1) = arrCoincidencias(j)
	next
	erase arr
	erase arrUnidades
	erase arrCoincidencias
	AnalizaArreglo = mtxUnidadesCoincidencias
End Function


analisisarray = Array(2,3,3,3,2,2,2,5,2,5,2)
r = OrdenaArreglo(analisisarray)
if not isNull(r) then
	matriz = AnalizaArreglo(r)
	if isArray(matriz) then
		Response.Write("| Numero | ")
		Response.Write("Coincidencias |" & "<br>")
		for j = 0 to uBound(matriz)
			Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & matriz(j,0) & "&nbsp;&nbsp;&nbsp;&nbsp;")
			Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & matriz(j,1) & "&nbsp;&nbsp;&nbsp;&nbsp;")
			Response.Write("<br>")
		next
	else
		'No hay resultados, despida al programador
	end if
else
	'No existe ningun arreglo
end if
%>
Salu2 y shupando que es gerundio!
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway