Professional Documents
Culture Documents
Module Module1
Sub Main()
Console.ForegroundColor = ConsoleColor.Magenta
Dim n As Integer
cdn(n)
Dim V1(n) As Integer
Dim V2(n) As Integer
leer(V1, n)
leer(V2, n)
End Sub
End Sub
Sub leer(ByRef v() As Integer, ByVal n As Integer)
Dim i As Integer
For i = 0 To n - 1
Randomize()
v(i) = CInt((50 * Rnd()) + 1)
Console.WriteLine("el número en la en posición {0} es {1}", i + 1, v(i))
Next
End Sub
Dim B As Single
For i = 0 To n - 1
suma = suma + Math.Log(V(i)) * Z(i)
suma_logx = suma_logx + Math.Log(V(i))
suma_y = suma_y + Z(i)
suma_logx2 = suma_logx2 + (Math.Log(V(i))) ^ 2
B = ((suma * n) - (suma_logx * suma_y)) / ((n * suma_logx2) - (suma_logx
^ 2))
Next
Return (B)
End Function
Function hallando_A(ByVal V() As Integer, ByVal Z() As Integer, ByVal n As
Integer)
Dim suma, suma_logx, suma_y As Single
suma = 0
suma_logx = 0
suma_y = 0
Dim A As Single
For i = 0 To n - 1
suma = suma + Math.Log(V(i)) * Z(i)
suma_logx = suma_logx + Math.Log(V(i))
suma_y = suma_y + Z(i)
Next
Return (A)
End Function
End Module
Exponencial
Module Module1
Sub Main()
Console.ForegroundColor = ConsoleColor.Cyan
Dim n As Integer
cdn(n)
Dim V1(n) As Integer
Dim V2(n) As Integer
leer_vector(V, n)
leer_vector(Z, n)
End Sub
End Sub
Sub leer_vector(ByRef v() As Integer, ByVal n As Integer)
Dim i As Integer
For i = 0 To n - 1
Randomize()
v(i) = CInt((50 * Rnd()) + 1)
Console.WriteLine("el número en la en posición {0} es {1}", i + 1, v(i))
Next
End Sub
Dim B As Single
For i = 0 To n - 1
suma_xlogy = suma_xlogy + Math.Log(Z(i)) * V(i)
suma_logx = suma_logx + Math.Log(V(i))
suma_logy = suma_logy + Z(i)
suma_logx2 = suma_logx2 + (Math.Log(V(i))) ^ 2
B = ((sumaxlogy * n) - (suma_logx * suma_logy)) / ((n * suma_logx2) -
(suma_logx ^ 2))
Next
Return (B)
End Function
Function hallando_A(ByVal V() As Integer, ByVal Z() As Integer, ByVal n As
Integer)
Dim suma_logx, suma_y As Single
suma_logx = 0
suma_logy = 0
Dim A As Single
For i = 0 To n - 1
suma_logx = suma_logx + Math.Log(V(i))
suma_logy = suma_y + math.log(Z(i))
Next
Return (A)
End Function
End Module
Interpolación Lineal
Module Module1
Sub Main()
Dim n As Integer
cantidad_n(n)
Dim V1(n) As Integer
Dim V2(n) As Integer
leer_vector(V1, V2, n)
max_min(V1, V2, n)
End Sub
Sub cantidad_n(ByRef n As Integer)
Console.SetCursorPosition(10, 1)
Console.ForegroundColor = ConsoleColor.Cyan
Randomize()
n = CInt((20 * Rnd()) + 1)
Console.WriteLine("n={0}", n)
Console.ReadLine()
End Sub
Sub leer_vector(ByRef V1() As Integer, ByRef V2() As Integer, ByVal n As
Integer)
Dim i As Integer
For i = 0 To n - 1
Randomize()
V1(i) = CInt((50 * Rnd()) + 1)
V2(i) = CInt((50 * Rnd()) + 1)
Console.ForegroundColor = ConsoleColor.Cyan
For i = 0 To n - 1
Next
Console.ForegroundColor = ConsoleColor.Cyan
Console.ReadLine()
A = y1 - ((x1 * (y2 - y1)) / (x2 - x1))
B = (y2 - y1) / (x2 - x1)
Console.ForegroundColor = ConsoleColor.Cyan
Console.WriteLine("La ecuación de interpolación lineal es Y= {0} + {1} * X",
A, B)
Console.ReadLine()
End Sub
End Module