elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Como puedo saber los números que faltan dentro del rango ?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 2 [3] Ir Abajo Respuesta Imprimir
Autor Tema: Como puedo saber los números que faltan dentro del rango ?  (Leído 13,507 veces)
luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Como puedo saber los números que faltan dentro del rango ?
« Respuesta #20 en: 24 Enero 2014, 16:52 pm »

Bien todavia super atascado

No habria una forma de comparar los resultados del array que contiene los resultados
con los numeros del 00 al 99 y que diga cuales faltan ?

Joe pense que esto era facil jejej.

Luis


En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Legnak

Desconectado Desconectado

Mensajes: 61


("Programador");


Ver Perfil
Re: Como puedo saber los números que faltan dentro del rango ?
« Respuesta #21 en: 25 Enero 2014, 17:31 pm »

Bien todavia super atascado

No habria una forma de comparar los resultados del array que contiene los resultados
con los numeros del 00 al 99 y que diga cuales faltan ?

Joe pense que esto era facil jejej.

Luis
en la respuesta que puse te deje un algoritmo sencillo de como hacer eso, y funciona


En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Como puedo saber los números que faltan dentro del rango ?
« Respuesta #22 en: 26 Enero 2014, 18:40 pm »

en la respuesta que puse te deje un algoritmo sencillo de como hacer eso, y funciona

Como ya comente en esto soy novato lo mio era el viejo foxpro jejej pongo el codigo pero me error

Código
  1. Public Class Form1
  2.  
  3.    Dim Max As Integer = 99
  4.    Dim Xmin As Integer = 0
  5.    Dim x As Integer = 0
  6.    Dim Número As Double
  7.  
  8.    Private TextBoxes As TextBox() = {Nothing}
  9.    Private Result1 As Int32(), Result2 As Int32(), Result3 As Int32()
  10.    Private _textBox As Object
  11.    Private _getNumbersNotInRange As Object
  12.  
  13.    Private Property ListBox1Count As Integer
  14.  
  15.    Private Property Calcular As Object
  16.  
  17.    Private Property TextBox(ByVal TextBoxCount As Short) As Object
  18.        Get
  19.            Return _textBox
  20.        End Get
  21.        Set(ByVal value As Object)
  22.            _textBox = value
  23.        End Set
  24.    End Property
  25.  
  26.  
  27.    ReadOnly Property Num1 As Int32
  28.        Get
  29.            Return CInt(TextBox1.Text)
  30.        End Get
  31.    End Property
  32.  
  33.    ReadOnly Property Num2 As Int32
  34.        Get
  35.            Return CInt(TextBox2.Text)
  36.        End Get
  37.    End Property
  38.    ReadOnly Property Num3 As Int32
  39.        Get
  40.            Return CInt(TextBox3.Text)
  41.        End Get
  42.    End Property
  43.  
  44.    Private Property GetNumbersNotInRange(ByVal Result11 As IEnumerable(Of Integer), ByVal Xmin As Integer, ByVal XMax As Integer) As Object
  45.        Get
  46.            Return _getNumbersNotInRange
  47.        End Get
  48.        Set(ByVal value As Object)
  49.            _getNumbersNotInRange = value
  50.        End Set
  51.    End Property
  52.  
  53.  
  54.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  55.  
  56.  
  57.  
  58.        Result1 = {Num1 + 10, Num1 + 20, Num1 + 30} _
  59.                  .Distinct().ToArray ' Elimino duplicados
  60.  
  61.        Result2 = {Num2 + 10, Num2 + 20, Num2 + 30} _
  62.                  .Distinct().ToArray ' Elimino duplicados
  63.  
  64.        Result3 = {Num3 + 10, Num3 + 20, Num3 + 30} _
  65.                  .Distinct().ToArray ' Elimino duplicados
  66.        ' primero concatenas y eliminas duplicados en el primer array:
  67.  
  68.        Dim Result11 As IEnumerable(Of Integer) =
  69.        (Result1.Concat(Result2).Concat(Result3).
  70.          Distinct)
  71.  
  72.  
  73.        ' Dim arregloSumas() As Integer = {10, 15, 20, 25, 30}
  74.        Dim numerosFaltantesdelRango() As Integer = {}
  75.        Dim rango_min As Integer = 0, rango_max As Integer = 99
  76.        Dim tamanio As Integer
  77.        Dim val As Integer
  78.  
  79.        For i = rango_min To rango_max
  80.            val = i
  81.            If Array.Exists(Result11, Function(value As Integer) value = val) = False Then 'Compruebo si el valor de i no aparece en el arreglo de las sumas
  82.                tamanio = numerosFaltantesdelRango.Length + 1
  83.                ReDim numerosFaltantesdelRango(tamanio)
  84.                numerosFaltantesdelRango(tamanio) = val 'Agrego el valor al arreglo
  85.            End If
  86.        Next
  87.        ListBox1.Items.AddRange(numerosFaltantesdelRango.Cast(Of Object).ToArray)
  88.    End Sub
  89. End Class
  90.  
« Última modificación: 27 Enero 2014, 16:47 pm por Eleкtro » En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Legnak

Desconectado Desconectado

Mensajes: 61


("Programador");


Ver Perfil
Re: Como puedo saber los números que faltan dentro del rango ?
« Respuesta #23 en: 28 Enero 2014, 01:07 am »

ahora si funciona  :)
Código
  1. Public Class Form1
  2.  
  3.    Dim Max As Integer = 99
  4.    Dim Xmin As Integer = 0
  5.    Dim x As Integer = 0
  6.    Dim Número As Double
  7.  
  8.    Private TextBoxes As TextBox() = {Nothing}
  9.    Private Result1 As Int32(), Result2 As Int32(), Result3 As Int32()
  10.    Private _textBox As Object
  11.    Private _getNumbersNotInRange As Object
  12.  
  13.    Private Property ListBox1Count As Integer
  14.  
  15.    Private Property Calcular As Object
  16.  
  17.    Private Property TextBox(ByVal TextBoxCount As Short) As Object
  18.        Get
  19.            Return _textBox
  20.        End Get
  21.        Set(ByVal value As Object)
  22.            _textBox = value
  23.        End Set
  24.    End Property
  25.  
  26.  
  27.    ReadOnly Property Num1 As Int32
  28.        Get
  29.            Return CInt(TextBox1.Text)
  30.        End Get
  31.    End Property
  32.  
  33.    ReadOnly Property Num2 As Int32
  34.        Get
  35.            Return CInt(TextBox2.Text)
  36.        End Get
  37.    End Property
  38.    ReadOnly Property Num3 As Int32
  39.        Get
  40.            Return CInt(TextBox3.Text)
  41.        End Get
  42.    End Property
  43.  
  44.    Private Property GetNumbersNotInRange(ByVal Result11 As IEnumerable(Of Integer), ByVal Xmin As Integer, ByVal XMax As Integer) As Object
  45.        Get
  46.            Return _getNumbersNotInRange
  47.        End Get
  48.        Set(ByVal value As Object)
  49.            _getNumbersNotInRange = value
  50.        End Set
  51.    End Property
  52.  
  53.  
  54.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  55.  
  56.  
  57.  
  58.        Result1 = {Num1 + 10, Num1 + 20, Num1 + 30} _
  59.                  .Distinct().ToArray ' Elimino duplicados
  60.  
  61.        Result2 = {Num2 + 10, Num2 + 20, Num2 + 30} _
  62.                  .Distinct().ToArray ' Elimino duplicados
  63.  
  64.        Result3 = {Num3 + 10, Num3 + 20, Num3 + 30} _
  65.                  .Distinct().ToArray ' Elimino duplicados
  66.        ' primero concatenas y eliminas duplicados en el primer array:
  67.  
  68.        Dim Result11 As IEnumerable(Of Integer) =
  69.        (Result1.Concat(Result2).Concat(Result3).
  70.          Distinct)
  71.  
  72.  
  73.        ' Dim arregloSumas() As Integer = {10, 15, 20, 25, 30}
  74.        Dim numerosFaltantesdelRango() As Integer = {}
  75.        Dim rango_min As Integer = 0, rango_max As Integer = 99
  76.        Dim tamanio As Integer
  77.        Dim val As Integer
  78.  
  79.  
  80.        Dim test As Integer
  81.        For i = rango_min To rango_max
  82.            val = i
  83.            If Array.Exists(Result11.Cast(Of Object).ToArray, Function(value As Integer) value = val) = False Then 'Compruebo si el valor de i no aparece en el arreglo de las sumas
  84.  
  85.                test += 1
  86.                tamanio = UBound(numerosFaltantesdelRango) + 1
  87.                ReDim Preserve numerosFaltantesdelRango(tamanio)
  88.                numerosFaltantesdelRango(tamanio) = val 'Agrego el valor al arreglo
  89.  
  90.            End If
  91.        Next
  92.  
  93.        ListBox1.Items.AddRange(numerosFaltantesdelRango.Cast(Of Object).ToArray)
  94.  
  95.    End Sub
  96. End Class
En línea

luis456


Desconectado Desconectado

Mensajes: 548



Ver Perfil
Re: Como puedo saber los números que faltan dentro del rango ?
« Respuesta #24 en: 28 Enero 2014, 11:43 am »

ahora si funciona  :)
Código
  1. Public Class Form1
  2.  
  3.    Dim Max As Integer = 99
  4.    Dim Xmin As Integer = 0
  5.    Dim x As Integer = 0
  6.    Dim Número As Double
  7.  
  8.    Private TextBoxes As TextBox() = {Nothing}
  9.    Private Result1 As Int32(), Result2 As Int32(), Result3 As Int32()
  10.    Private _textBox As Object
  11.    Private _getNumbersNotInRange As Object
  12.  
  13.    Private Property ListBox1Count As Integer
  14.  
  15.    Private Property Calcular As Object
  16.  
  17.    Private Property TextBox(ByVal TextBoxCount As Short) As Object
  18.        Get
  19.            Return _textBox
  20.        End Get
  21.        Set(ByVal value As Object)
  22.            _textBox = value
  23.        End Set
  24.    End Property
  25.  
  26.  
  27.    ReadOnly Property Num1 As Int32
  28.        Get
  29.            Return CInt(TextBox1.Text)
  30.        End Get
  31.    End Property
  32.  
  33.    ReadOnly Property Num2 As Int32
  34.        Get
  35.            Return CInt(TextBox2.Text)
  36.        End Get
  37.    End Property
  38.    ReadOnly Property Num3 As Int32
  39.        Get
  40.            Return CInt(TextBox3.Text)
  41.        End Get
  42.    End Property
  43.  
  44.    Private Property GetNumbersNotInRange(ByVal Result11 As IEnumerable(Of Integer), ByVal Xmin As Integer, ByVal XMax As Integer) As Object
  45.        Get
  46.            Return _getNumbersNotInRange
  47.        End Get
  48.        Set(ByVal value As Object)
  49.            _getNumbersNotInRange = value
  50.        End Set
  51.    End Property
  52.  
  53.  
  54.    Private Sub Sumar(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  55.  
  56.  
  57.  
  58.        Result1 = {Num1 + 10, Num1 + 20, Num1 + 30} _
  59.                  .Distinct().ToArray ' Elimino duplicados
  60.  
  61.        Result2 = {Num2 + 10, Num2 + 20, Num2 + 30} _
  62.                  .Distinct().ToArray ' Elimino duplicados
  63.  
  64.        Result3 = {Num3 + 10, Num3 + 20, Num3 + 30} _
  65.                  .Distinct().ToArray ' Elimino duplicados
  66.        ' primero concatenas y eliminas duplicados en el primer array:
  67.  
  68.        Dim Result11 As IEnumerable(Of Integer) =
  69.        (Result1.Concat(Result2).Concat(Result3).
  70.          Distinct)
  71.  
  72.  
  73.        ' Dim arregloSumas() As Integer = {10, 15, 20, 25, 30}
  74.        Dim numerosFaltantesdelRango() As Integer = {}
  75.        Dim rango_min As Integer = 0, rango_max As Integer = 99
  76.        Dim tamanio As Integer
  77.        Dim val As Integer
  78.  
  79.  
  80.        Dim test As Integer
  81.        For i = rango_min To rango_max
  82.            val = i
  83.            If Array.Exists(Result11.Cast(Of Object).ToArray, Function(value As Integer) value = val) = False Then 'Compruebo si el valor de i no aparece en el arreglo de las sumas
  84.  
  85.                test += 1
  86.                tamanio = UBound(numerosFaltantesdelRango) + 1
  87.                ReDim Preserve numerosFaltantesdelRango(tamanio)
  88.                numerosFaltantesdelRango(tamanio) = val 'Agrego el valor al arreglo
  89.  
  90.            End If
  91.        Next
  92.  
  93.        ListBox1.Items.AddRange(numerosFaltantesdelRango.Cast(Of Object).ToArray)
  94.  
  95.    End Sub
  96. End Class



Perfecto perfecto  ;-)  ;-)  ;-)

Funciona como quería ¡ muchas gracias por tu ayuda

Luis


En línea

Que tu sabiduria no sea motivo de Humillacion para los demas
Páginas: 1 2 [3] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines