
14/10/2004, 12:16
|
 | Moderador | | Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 23 años, 4 meses Puntos: 98 | |
Bueno, de todas formas te dejo este código:
Código:
<%
'Dimesionamos las matrices necesarias
Dim matriz(19, 1)
Dim matrizBIS(19, 1)
'Asignamos valor a la matriz, esta se supone que debería llegar con valores
For i = 0 to 19
For x = 0 to 1
matriz(i, x) = i + 1
Next
Next
'Ponemos los valores necesarios duplicados
matriz(3, 0) = 1
matriz(3, 1) = 10
matriz(6, 0) = 2
matriz(6, 1) = 2
'SIrve para imprimir la matriz final matrizBIS
Sub ImprimeMatriz()
For y = 0 to 19
Response.Write "Indice " & y & ": " & matrizBIS(y, 0) & " = " & matrizBIS(y, 1) & "<br>"
Next
End Sub
'Regresa el número de renglones ocupados de matrizBIS
Function CuentaIndice()
For j = 0 to 19
If matrizBIS(j, 0) = "" Then
Exit For
End If
Next
CuentaIndice = j
End Function
'Determina si un índice está repetido en la matriz final
Function IndiceRepetido(queIndice)
repetido = false
For r = 0 to 19
If cint(queIndice) = cint(matrizBIS(r, 0)) Then
repetido = true
Exit For
End If
Next
IndiceRepetido = repetido
End Function
'Aqui todo el show de comparar cada índice de la matriz con los siguientes
For i = 0 to 19
valor = 0
mi_indice = matriz(i, 0)
repetido = IndiceRepetido(mi_indice)
If not repetido Then
valor = matriz(i, 1)
For z = i + 1 to 19
If cint(mi_indice) = cint(matriz(z, 0)) Then
valor = valor + matriz(z, 1)
End If
Next
insertaEn = CuentaIndice()
matrizBIS(InsertaEn, 0) = mi_indice
matrizBIS(InsertaEn, 1) = valor
End If
Next
'Imprimimos
ImprimeMatriz
%>
Tu solución es mas sencilla
Salu2,
__________________ "El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway |