Académique Documents
Professionnel Documents
Culture Documents
Diagrama de flujo
Leer N
Console.WriteLine("Ingrese un nmero")
N = Console.ReadLine()
En Pseudocdigo:
Inicio
Leer N
Mostrar N
Fin
Pseudocdigo
SUMA = N1 + N2
Pseudocdigo:
Inicio
Leer N1
Leer N2
SUMA = N1 + N2
Mostrar SUMA
Fin
Visual Basic .Net:
Module Module1
Sub Main()
Dim N1 As Integer
Dim N2 As Integer
Dim SUM As Integer
Console.WriteLine("Ingrese el primer valor")
N1 = Console.ReadLine
Console.WriteLine("Ingrese el segundo valor")
N2 = Console.ReadLine
SUM = N1 + N2
Console.WriteLine("La suma de los valores ingresados es: {0}", SUM)
Console.ReadLine()
End Sub
End Module
Diagrama de flujo
Pseudocdigo
Si N > 10 entonces:
If N > 10 Then
Fin Si
End If
Ej: Ingresar dos valores. Si los valores son mayores a 10, sumarlos. Si no, finalizar el
algoritmo.
Diagrama de flujo:
Pseudocdigo:
Inicio
Leer N1
Si N1>0 entonces:
Leer N2
Si N2>10 entonces:
SUM = N1 + N2
Mostrar SUM
Fin Si
Fin Si
Fin
Pseudocdigo
Para i=1 a 50
Leer N
Fin Para
Visual Basic .Net
For i = 1 To 50
Console.WriteLine("Ingrese un nmero")
N = Console.ReadLine()
Next
Pseudocdigo:
Inicio
SUMA = 0
Para i=1 a 5
Leer N
SUMA = SUMA + N
Fin Para
Mostrar SUMA
Fin
Pseudocdigo:
Inicio
c=0
Para i=1 a 50
Leer N
Si c=0 entonces
c=1
M=N
Fin Si
Si N > M entonces
M=N
Fin Si
Fin Para
Mostrar M
Fin
Visual Basic .Net:
Module Module1
Sub Main()
Dim c As Integer
Dim N As Integer
Dim M As Integer
c=0
For i = 1 To 50
Console.WriteLine("Ingresar nmero")
N = Console.ReadLine()
If c = 0 Then
c=1
M=N
End If
If N > M Then
M=N
End If
Next
Console.WriteLine("El mximo de los valores ingresados es: {0}", M)
Console.ReadLine()
End Sub
End Module
Ej: Ingresar 200 valores y obtener mximo, mnimo y diferencia entre ambos.
Pseudocdigo:
Inicio
Para i = 1 a 200
Leer N
Si i=1 entonces
MAX = N ; min = N
Fin Si
Si N > MAX entonces
MAX = N
Fin Si
Si N < min entonces
min = N
Fin Si
Fin Para
DIF=MAX - min
Mostrar MAX ; min ; DIF
Fin
N As Integer
MAX As Integer
min As Integer
DIF As Integer
For i = 1 To 200
Console.WriteLine("Ingresar nmero")
N = Console.ReadLine()
If i = 1 Then
MAX = N
min = N
End If
If N > MAX Then
MAX = N
End If
If N < min Then
min = N
End If
Next
DIF = MAX - min
Console.WriteLine("El mximo de los valores ingresados es: {0}", MAX)
Console.ReadLine()
Console.WriteLine("El mnimo de los valores ingresados es: {0}", min)
Console.ReadLine()
Console.WriteLine("La diferencia entre el mximo y el mnimo es de: {0}", DIF)
Console.ReadLine()
End Sub
End Module
UTILIZACIN DE ACUMULADORES
Ej: Se tiene un listado de 20 valores numricos. Sabiendo que los diez primeros son
enteros positivos y el resto negativos, determinar el promedio de los valores positivos. Si
el promedio de los valores positivos es mayor a 30 determinar el promedio de los
negativos.
Pseudocdigo
Inicio
S1 = 0 ; S2 = 0
Para i = 1 a 200
Leer N
Si N > 10 entonces
S1 = S1 + N
Si no
S2 = S2 + N
Fin Si
Fin Para
P1 = S1 / 10
Mostrar P1
Si P1 > 30 entonces
P2 = S2 / 10
Mostrar P2
Fin Si
Fin
Visual Basic .Net
Module Module1
Sub Main()
Dim N As Integer
Dim S1 As Integer
Dim S2 As Integer
Dim P1 As Integer
Dim P2 As Integer
S1 = 0
S2 = 0
For i = 1 To 200
Console.WriteLine("Ingrese un nmero de la lista")
N = Console.ReadLine
If N > 0 Then
S1 = S1 + N
Else
S2 = S2 + N
End If
Next
P1 = S1 / 10
Console.WriteLine("El promedio de los valores positivos es: {0}", P1)
Console.ReadLine()
If P1 > 30 Then
P2 = S2 / 10
Console.WriteLine("El promedio de los valores negativos es: {0}", P2)
Console.ReadLine()
End If
End Sub
End Module
Se utiliza el smbolo:
&