jueves, 15 de mayo de 2008

Solución de la Hoja Nº 7 - Tecnología de la Información

Pues nada, aquí van las soluciones de los 5 ejercicios, espero que todo el mundo identifique dónde ha fallado, para que no vuelva a ocurrir.

Function SumaImpares(Final As Integer) As Long
___Dim I As Integer
___Dim Suma As Long
___Suma = 0
___For I = 1 to Final Step 2
______Suma = Suma + I
___Next I
___SumaImpares = Suma
End Function


Function ObtenerMayor(Datos() As Single) As Single
___Dim I As Integer
___Dim Mayor as Single
___Mayor = Datos(1)
___For I = 2 to 100
______If Datos(I) > Mayor Then
_________Mayor = Datos(I)
______End if
___Next I
___ObtenerMayor = Mayor
End Function


Function VolumenCilindro(Radio As Single, Altura As Single) As Double
___VolumenCilindro = (3,14159*Radio^2)*Altura
End Function


Function MediaAritmetica(Valores() As Single) As Single
___Dim I As Intger
___Dim Suma As Double
___Suma = 0
___For I = 1 to 500
______Suma = Suma + Valores(I)
___Next I
___MediaAritmetica = Suma/500
End Function


Sub OrdenaBurbuja(Datos() As Single, Numero As Integer)
___Dim I, J AS Integer
___For J = 2 To Numero
______For I = Numero To J Step -1
_________If Datos(I) > Datos(I-1) Then
____________Dim Aux As Single
____________Aux = Datos(I)
____________Datos(I) = Datos(I-1)
____________Datos(I-1) = Aux
_________End If
______Next I
___Next J
End Sub

No hay comentarios: