domingo, 11 de marzo de 2012

Practica 7 Unidad 2

Problema 1
Programa para calcular la suma de los primeros 50 enteros
Inicio
suma = 0, i = 1 Int 
for ( i = 1; i <= 50; i++ )
{  suma = suma + i
}  Print "La suma de los primeros 50 enteros es ", suma
Fin 
Problema 2
Programa para calcular la suma de la serie
Inicio
serie = 0.0 Real
n = 0, c = 0 Int
Print "Numero determinado de la serie= "
Read n
for ( c = 1; c <= n; c++ )
{  if ( c%2== 0 )
{  serie = serie - c / pow ( 2,c )
} else
{  serie = serie + c / pow ( 2,c )
}
}
Print "Suma de la serie es: ", serie
Fin
Problema 3
Programa para una serie de caracteres 
Inicio
numerolinea = 0, c1= 0, c2 = 0 Int
Print "Numero de lineas "
Read numerolinea
for ( c1 = 1; c1 <= numerolinea; c1++ )
{  for ( c2 = 1; c2 <= c1; c2++ )
{  Print "*"
}  Print / n
}
Fin
Problema 4
Programa para ver si un numero es positivo, negativo o cero.
Inicio
n = 0, numero = 0, np = 0, nn = 0, nc =, c1 = 1 Int
Print "Introduce numero de elementos numeros enteros / n"
Read n
Print "Introduce valores enteros positivos, negativos o cero / n"
for ( c1=1; c1<=n; c1++ )
{  Print "Valor numerico entero= "
    Read numero
if  ( numero < 0 )
{  nn = nn + 1
}  else
{  if ( numero > 0 )
{  np = np + 1
}  else
{  nc = nc + 1
}
}
}
Print "Cantidad de numeros positivos: ", np
Print "Cantidad de numeros negativos: ", nn
Print "Cantidad de valores ceros: ", nc
Fin
Problema 5
Programa para ver numero es primo o no 
Inicio
n = 0, opcion = 0, numero = 0, c1 = 0 Int
do
{  n = 0
Print "Introduce el valor entero = "
Read numero
for ( c1= 1; c1<=numero; c1++ )
{  if ( numero %c1 == 0 )
{  n = n + 1
}
}
if ( n == 2 )
{  Print numero, "es un numero primo"
}  else
{  Print numero, "es un numero no primo"
}  Print " Desea validar otro numero 1) si 0 ) no = "
    Read opcion
}
while ( opcion == 1)
Fin
Problema 6
Programa para calcular produccion de vinos
Inicio
n = 0, v1= 0, v2= 0, v3= 0, v4= 0, v5= 0, total= 0, c1= 0, cantidad= 0 Int
Print "Cantidad de anos a evaluar los vinos= "
Read n 
for ( c1=1 to n step c1= c1 +1 )
Print "Cantidad de vino tipo 1= "
Read cantidad
v1= v1 + cantidad
Print "Cantidad de vino tipo 2= "
Read cantidad
v2= v2 + cantidad
Print "Cantidad de vino tipo 3= "
Read cantidad
v3= v3 + cantidad
Print "Cantidad de vino tipo 4= "
Read cantidad
v4= v4 + cantidad
Print "Cantidad de vino tipo 5= "
Read cantidad
v5= v5 + cantidad
total = v1 + v2 + v3 + v4 + v5
Print "Producto total de vino es ", total
if ( v1 >= v2 and v1 >= v3 and v1 >= v4 and v1 >= v5 )
{ Print "La cantidad mayor de vino es tipo 1 total de litros es ", v1
} else 
{ if ( v2 >= v1 and v2 >= v3 and v2 >= v4 and v2 >= v5 )
{ Print "La cantidad mayor de vino es tipo 2 total de litros es ", v2
} else
{ if ( v3 >= v1 and v3 >= v2 and v3 >= v4 and v3 >= v5 )
{ Print "La cantidad mayor de vino es tipo 3 total de litros es ", v3
} else
{ if ( v4 >= v1 and v4 >= v2 and v4 >= v3 and v4 >= v5 ) 
{ Print "La cantidad mayor de vino es tipo 4 total de litros", v4
} else 
{ Print "La cantidad mayor de vino es tipo 5 total de litros es", v5
}
}
}
}
if ( v1 <= v2 and v1 <= v3 and v1 <= v4 and v1 <= v5 )
{ Print "La cantidad menor de vino es tipo 1 total de litros es ", v1
} else 
{ if ( v2 <= v1 and v2 <= v3 and v2 <= v4 and v2 <= v5 )
{ Print "La cantidad menor de vino es tipo 2 total de litros es ", v2
} else
{ if ( v3 <= v1 and v3 <= v2 and v3 <= v4 and v3 <= v5 )
{ Print "La cantidad menor de vino es tipo 3 total de litros es ", v3
} else
{ if ( v4 <= v1 and v4 <= v2 and v4 <= v3 and v4 <= v5 ) 
{ Print "La cantidad menor de vino es tipo 4 total de litros", v4
} else 
{ Print "La cantidad menor de vino es tipo 5 total de litros es", v5
}
}
}
}
Fin 








No hay comentarios:

Publicar un comentario