Ejercicio
Matriz de estructura
Objetivo
Expanda el ejercicio anterior (punto de estructura), de modo que se puedan almacenar hasta 1.000 puntos, utilizando una "matriz de estructura". Pida al usuario datos para los dos primeros puntos y luego muéstrelos.
Código
Imports System
Public Class exercise80
Structure point
Public x As Short
Public y As Short
Public r As Byte
Public g As Byte
Public b As Byte
End Structure
Public Shared Sub Main()
Dim p As point() = New point(999) {}
Console.Write("Enter X for first point: ")
p(0).x = Convert.ToInt16(Console.ReadLine())
Console.Write("Enter Y for first point: ")
p(0).y = Convert.ToInt16(Console.ReadLine())
Console.Write("Enter Red for first point: ")
p(0).r = Convert.ToByte(Console.ReadLine())
Console.Write("Enter Green for first point: ")
p(0).g = Convert.ToByte(Console.ReadLine())
Console.Write("Enter Blue for first point: ")
p(0).b = Convert.ToByte(Console.ReadLine())
Console.Write("Enter X for second point: ")
p(1).x = Convert.ToInt16(Console.ReadLine())
Console.Write("Enter Y for second point: ")
p(1).y = Convert.ToInt16(Console.ReadLine())
Console.Write("Enter Red for second point: ")
p(1).r = Convert.ToByte(Console.ReadLine())
Console.Write("Enter Green for second point: ")
p(1).g = Convert.ToByte(Console.ReadLine())
Console.Write("Enter Blue for second point: ")
p(1).b = Convert.ToByte(Console.ReadLine())
Console.WriteLine("P1 is located in ({0},{1}), colour ({2},{3},{4})", p(0).x, p(0).y, p(0).r, p(0).g, p(0).b)
Console.WriteLine("P2 is located in ({0},{1}), colour ({2},{3},{4})", p(1).x, p(1).y, p(1).r, p(1).g, p(1).b)
End Sub
End Class