Anda di halaman 1dari 36

UNIVERSIDAD CENTRAL DEL ECUADOR

FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

TRABAJO DE PROGRAMACIN
1. Leer 5 nmeros e imprimir la suma de ellos.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int A, B, C, D, E, R;
//DECLARO LAS 6 VARIABLES, 5 ENTEROS SUMA Y RESPUESTA
Console.WriteLine("Bienvenidos ingrese 5 numeros");
//IMPRIMO EN LA PANTALLA EL MENSAJE INICIAL
A = Convert.ToInt32(Console.ReadLine());
//ASIGNO UN NUMERO A "A"
Console.WriteLine("Ingrese el siguiente numero");
B = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ingrese el siguiente numero");
C = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ingrese el siguiente numero");
D = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ingrese el siguiente numero");
E = Convert.ToInt32(Console.ReadLine());
R = A + B + C + D + E;
//REALIZO LA SUMA
Console.WriteLine("EL RESULTADO ES {0}", R);
//IMPRIMO EL REUSLTADO DE LA SUMA
Console.Read();
//LEO LAS VARIABLES Y EL RESULTADO
}
}
}

2. Imprimir los 10 primeros nmeros naturales.


using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_N2
{
class Program
{
static void Main(string[] args)
{
int i;

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
//DECLARO LA VARIABLE
for (i = 1; i <= 10; i++)
//INDICO QUE PARA I ASIGNELE 1 Y CUENTE HASTA 10
Console.WriteLine("Uno de los primeros 10 numeros naturales es {0}", i);
//ESCRIBA LOS NUMEROS CONTADOS
Console.Read();
//LEA LO ESCRITO
}
}
}

3. Sumar los 10 primeros nmeros naturales e imprimir el resultado final.


using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 10;
// DEFINO LA VARIABLE Y LE ASIGNO EL NUMERO DE ENTEROS A SUMAR
int b;
// DEFINO UNA VARIABLE PARA APLICAR LA FORMULA (RESP = (N*(N + 1))/2) QUE
AYUDARA A RESOLVER EL PROBLEMA
string resp;
//El tipo string representa una secuencia de cero o ms caracteres
b = (a*(a + 1))/2;
// APLICO LA FORMULA PARA OBTENER LA SUMA DE ENTEROS
resp = Convert.ToString(b);
Console.WriteLine("LA SUMA DE LOS PRIMEROS 10 NUMEROS NATURALES ES: "
+ resp);
// IMPRIMO EL RESULTADO
Console.Read();
// LEO LO IMPRESO
}
}
}

4. Dado un valor entero (X), mayor que cero (0). Imprimir por pantalla el
resultado de multiplicar a cada uno de sus antecesores por 2.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine
(".......................BIENVENIDOS AL PROGRAMA....................");
Console.WriteLine
("INGRESE UN NUMERO PARA CONOCER SUS ANTECESORES MULTIPLICADOS POR
2");
int a = 0;
int cont = 1;
// DECLARAR VARIABLES E INICIALIZAR EL CONTADOR
a = Int32.Parse(Console.ReadLine());
//LEER EL NUMERO INGRESADO POR TECLADO
if (a <= 0)//CREAR CONDICION
{
Console.WriteLine("INGRESAR SOLO NUMEROS MAYORES A CERO");
Console.ReadLine();
}
else//CASO CONTRARIO DE LA CONDICION
{
while (cont < a)//CONDICION DEL CONTADOR
{
Console.WriteLine
("EL ANTECESOR NUMERO " + cont + " MULTIPLICADO POR 2 ES");
int produc = cont * 2;
cont = cont + 1;//INCREMENTA AL CONTADOR
Console.WriteLine(produc);
}
Console.ReadLine();
}
}

5. Dado dos valores enteros (X) y (Y) ambos mayores que cero (0), contar la
cantidad de un nmero que haya dentro de ese rango de valores
determinados por (X) y (Y).
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int A, B, J, K, RANGO;
Console.WriteLine("Ingrese dos numeros");
A = Convert.ToInt32(Console.ReadLine());

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
//ASIGNO UN NUMERO A "A"
Console.WriteLine("Ingrese el siguiente numero");
B = Convert.ToInt32(Console.ReadLine());
J = A-B;
K = B-A;
{
if (A==0 || B==0)
{
Console.WriteLine("Ingrese un numero diferente de cero");
Console.ReadLine();
}
if (A<B)
{
RANGO = (K-1);
Console.WriteLine("EL RANGO ES," +RANGO+ "");
Console.ReadLine();
}
if (B<A)
{
RANGO = (J-1);
Console.WriteLine("EL RANGO ES," +RANGO+ "");
Console.ReadLine();
}
}
}

6. Leer un valor hasta que este sea mayor que cero.


namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int A;
do
{
Console.WriteLine("INGRESE UN NUMERO");
A = Convert.ToInt32(Console.ReadLine());
}
while (A <= 0);
Console.WriteLine("EL NUMERO INGRESADO ES MAYOR A CERO");
Console.ReadLine();
}
}
}

7. Leer una serie de nmeros terminada en cero e imprimir el promedio.

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
using
System;
using

System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EJERCICIO_7
{
class Program
{
static void Main(string[] args)
{
int COUNT = 0;
double SUM = 0;
double NUM;
double prom;
Console.WriteLine("INGRESE EL CERO PARA TERMINAR");
Console.WriteLine(" ");
do
{
Console.WriteLine("INGRESE UNA CANTIDAD");
double n = int.Parse(Console.ReadLine());
SUM = SUM + n;
COUNT = COUNT + 1;
NUM = n;
}
while (NUM != 0);
prom = (double) SUM / (COUNT - 1);
Console.WriteLine("EL PROMEDIO ES: " + prom);
Console.ReadLine();
}
}
}

8. Dado un valor entero (Y) , mayor que cero (0), contar cuantos nmeros
pares y cuantos nmeros impares existen dentro de ese rango.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
static void Main(string[] args)
{
Console.WriteLine("INGRESE UN NUMERO MAYOR A CERO");
int a, z, contpar, contimp,cont;
contimp = 0;
contpar = 0;
a = Int32.Parse(Console.ReadLine());
z = a % 2;
if (z == 0)
{
for (cont = 1; cont < a; cont++)
{
contpar = cont;
contimp = cont;
contimp = (contimp + 1) / 2;
contpar = (contpar - 1) / 2;
}
}
else {
for (cont = 1; cont < a; cont++)
{
contimp = cont / 2;
contpar = cont / 2;

}
}
Console.WriteLine
("existen " + contimp + " numeros impares en el rango");
Console.WriteLine
("existen " + contpar + " numeros pares en el rango");
Console.ReadLine();

}
}

9. Dada una cadena (p), y un carcter (c) , encontrar las apariciones de la


letra obtenida en la variable (c) dentro de la cadena (p). Ejemplo. Palabra
= caracas, c= a, El resultado a obtener debe ser: La letra a aparece
3 veces.
Ayuda
Asuma que existen las siguientes funciones:
a) Largo (cadena): devuelve la cantidad de caracteres que tiene la
palabra suministrada.
b) Ejemplo p= caracas, la funcin largo (p) devuelve 7.
c) Obtener_ carcter (cadenas, pos_ ini ,1): devuelve un carcter
a partir de la posicin inicial dada. Ejemplo p= caracas, la
funcin obtener _ c ar-ac-ter
(p, 2,1) devuelve a.
10. Dado una cadena, indicar si la misma es capica. Una cadena de
caracteres es capica o palndromo si se lee igual de izquierda a

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
derecha, que de derecha a izquierda. Ejemplo ana, ata, somos asa son
capica.
namespace EJERCICIO N10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cmdevaluar_Click(object sender, EventArgs e)
{
string frase = "";
int patito = 0;
string letra1 = "";
string letra2 = "";
string polindrome="";
string cadena = "";
frase = txtfrase.Text;

for (int r = 0; r < frase.Length; r++)


{
if (frase[r].ToString() != " ")
{
cadena = cadena + frase[r].ToString();
}
}
patito = cadena.Length-1;
for (int i = 0; i < cadena.Length/2; i++)
{
letra1 = cadena.Substring(i,1);
letra2 = cadena.Substring(patito, 1);
if (letra1 == letra2)
{
polindrome = "si";
}
else
{
polindrome = "no";
}
patito = patito - 1;
}
if (palindrome == "si")
MessageBox.Show("Es un Polindrome");
if (polindrome == "no")
MessageBox.Show("No es un Polindrome");
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

11. Imprimir y contar los nmeros que son mltiplos de 2 o 3 que hay
entre 1 y 100.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace Ejerc_11
{
class Program
{
static void Main(string[] args)
{
int[] NUMS = new int[5];
for (int x = 0; x <= 4; x++)
NUMS[x] = 0;
for (int x = 0; x <= 4; x++)
{
Console.WriteLine("INGRESE UN DIGITO PARA ALMACENARLO");
NUMS[x] = int.Parse(Console.ReadLine());
}
Console.WriteLine("LOS NUMEROS PRIMOS SON: ");
for (int x = 0; x <= 4; x++)
{
int CONTADOR = 1;
int FCT = 1;
if (NUMS[x] >= 1)
{
do
{
FCT = FCT * CONTADOR;
CONTADOR++;
}
while (CONTADOR < NUMS[x]);
if ((FCT + 1) % NUMS[x] == 0)
Console.WriteLine(NUMS[x]);
}
}
Console.ReadLine();
}
}
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

12. Hacer un seudocdigo que imprima los nmeros del 1 al 100. Que
calcule la suma de todos los nmeros pares por un lado, y por otro, la de
todos los impares.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int CONT, K, SUMA, X;
X = 1;
SUMA = 0;
CONT = 0;
K = 1;
Console.WriteLine("LOS NUMEROS DEL 1 AL 100 SON");
while (X <= 100)
{
Console.WriteLine(X);
X = X + 1;
}
while (CONT <= 100)
{
SUMA = SUMA + CONT;
CONT = CONT + 2;
}
Console.WriteLine("LA SUMA DE TODOS LOS PARES DEL 1 AL 100 ES "+SUMA);
while (K <= 100)
{
SUMA = SUMA + K;

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
K = K + 2;
}
Console.WriteLine
("LA SUMA DE TODOS LOS IMPARES DEL 1 AL 100 ES " + SUMA);
Console.ReadLine();
}
}

13. Imprimir y contar los mltiplos de 3 desde la unidad hasta un nmero


que introducimos por teclado.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int N, CONT, Z;
Console.WriteLine("INGRESE UN NUMERO");
N = Int32.Parse(Console.ReadLine());
CONT = 0;
Z = 0;
Console.WriteLine
("LOS MULTIPLOS DE 3 DESDE LA UNIDAD HASTA EL NUMERO INGRESADO
SON");
while (CONT < (N - 2))
{
Z = Z + 1;
CONT = CONT + 3;
Console.WriteLine(CONT);
}
Console.WriteLine("HAY "+Z+" MULTIPLOS DE 3");
Console.ReadLine();
}
}
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

14. Imprimir, contar y sumar los mltiplos de 2 que hay entre una serie
de nmeros, tal que el segundo sea mayor o igual que el primero.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, suma, j, z, x;
Console.WriteLine("INGRESE UN NUMERO MENOR");
a = Int32.Parse(Console.ReadLine());
Console.WriteLine("INGRESE UN NUMERO MAYOR");
b = Int32.Parse(Console.ReadLine());
suma = 0;
j = 0;
Console.WriteLine();
if (a <= b)
{
Console.WriteLine("LOS NUMEROS DENTRO DEL RANGO SON: ");
Console.WriteLine();
x = a;
while (a < b - 1)
{
a = a + 1;
Console.WriteLine(a);
}
while (x < b - 1)
{
x = x + 1;
z = x % 2;
if (z == 0)
{
Console.WriteLine
("LOS MULTIPLOS DE 2 EN LA SERIE SON " + x);
j = j + 1;
suma = suma + x;
}
}
Console.WriteLine();
Console.WriteLine
("LA SUMA DE LOS MULTIPLOS DE 2 EN LA SERIE SON " + suma);
Console.WriteLine();
Console.WriteLine
(" Y EXISTEN " + j + " MULTIPLOS DE 2 EN ESTA SERIE");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
Console.ReadLine();
}
else;
Console.WriteLine
("INGRESE PRIMERO UN NUMERO MENOR LUEGO UN MAYOR O IGUAL ");
Console.ReadLine();
}
}

15. Hacer un pseudocdigo que simule el funcionamiento de un reloj


digital y que permita ponerlo en hora.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, c, x, z, j;
Console.WriteLine("INGRESAR HORAS");
a = Int32.Parse(Console.ReadLine());
Console.WriteLine("INGRESAR MINUTOS");
b = Int32.Parse(Console.ReadLine());
Console.WriteLine("INGRESAR SEGUNDOS");
c = Int32.Parse(Console.ReadLine());
for (x = a; x <= 23; x++)
{
for (z = b; z <= 59; z++)
{
for (j = c; j <= 59; j++) ;
Console.WriteLine(x + ":" + z + ":" + j);
}
}
Console.ReadLine();
}
}
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

16. Leer una secuencia de nmeros y mostrar la suma de los pares y el


producto de los que son mltiplo de 5.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_16
{
class Program
{
static void Main(string[] args)
{
int[] SEC = new int[5];
int SUM = 0;
int MULT = 1;
for (int a = 0; a <= 4; a++)
{
SEC[a] = 0;
}
for (int a = 0; a <= 4; a++)
{
Console.WriteLine("INGRESE NUMEROS ENTEROS");
SEC[a] = int.Parse(Console.ReadLine());
}
for (int a = 0; a <= 4; a++)
{
if (SEC[a] % 2 == 0)
SUM = SUM + SEC[a];
if (SEC[a] % 5 == 0)
MULT = MULT * SEC[a];
}
Console.WriteLine("");
Console.WriteLine("EL PRODUCTO DE LOS MULTIPLOS DEL CINCO ES:" + MULT);
Console.WriteLine("");
Console.WriteLine("LA SUMA DE LOS PARES ES: " + SUM);
Console.ReadLine();
}
}
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

17.
Leer una secuencia de nmeros y determinar el mayor de los pares
ledos.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_17
{
class Program
{
static void Main(string[] args)
{
int[] SEC = new int[5];
for (int a = 0; a <= 4; a++)
{
SEC[a] = 0;
}
for (int a = 0; a <= 4; a++)
{
Console.WriteLine("INGRESE UN NUMERO ENTERO");
SEC[a] = int.Parse(Console.ReadLine());
}
int MAY = SEC[0];
for (int a = 0; a <= 4; a++)
{
if ((SEC[a] % 2 == 0) & (SEC[a] > MAY))
MAY = SEC[a];
}
if (MAY != SEC[0])
{
Console.WriteLine(" ");
Console.WriteLine("EL NUMERO PAR MAYOR ES EL: " + MAY);
Console.ReadLine();
}
else
{
if (MAY % 2 == 0)
{
Console.WriteLine(" ");
Console.WriteLine("EL NUMERO PAR MAYOR ES EL: " + MAY);
Console.ReadLine();
}
else
{
Console.WriteLine("NO EXISTEN NUMEROS PARES");
Console.ReadLine();
}
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

18. Leer una secuencia de nmeros y mostrar el mayor de los mltiplos


de 5 ledos y el menor de los mltiplos de 3 ledos.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EjJERCICO_18
{
class Program
{
static void Main(string[] args)
{
int[] secu = new int[10];
for (int a = 0; a <= 9; a++)
secu[a] = 0;
for (int a = 0; a <= 9; a++)
{
Console.WriteLine("INGRESE UN NUMERO ENTERO");
secu[a] = int.Parse(Console.ReadLine());
}
int myr = secu[0];
int mnr = secu[1];
for (int a = 0; a <= 9; a++)
{
if ((secu[a] % 5 == 0) & (secu[a] > myr))
myr = secu[a];
if ((secu[a] % 3 == 0) & (secu[a] < mnr))
mnr = secu[a];
}
if ((myr != secu[0]) & (mnr != secu[1]))
{
Console.WriteLine
("EL NUMERO MAYOR Y MULTIPLO DE CINCO ES: " + myr);
Console.WriteLine
("EL NUMERO MENOR Y MULTIPLO DE TRES ES: " + mnr);
Console.ReadLine();
}
if ((myr != secu[0]) & (mnr == secu[1]))
{
Console.WriteLine
("EL NUMERO MAYOR Y MULTIPLO DE CINCO ES: " + myr);
if (mnr % 3 == 0)
{
Console.WriteLine
("EL NUMERO MENOR Y MULTIPLO DE TRES ES: " + mnr);
Console.ReadLine();
}
else

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
{

Console.WriteLine("NO HAY MULTIPLOS DE TRES");


Console.ReadLine();

}
}
if ((myr == secu[0]) & (mnr != secu[1]))
{

if (myr % 5 == 0)
Console.WriteLine
("EL NUMERO MAYOR Y MULTIPLO DE CINCO ES: " + myr);
else
Console.WriteLine("NO HAY MULTIPLOS DE CINCO");
Console.WriteLine
("EL NUMERO MENOR Y MULTIPLO DE TRES ES: " + mnr);
Console.ReadLine();
}
if ((myr == secu[0]) & (mnr == secu[1]))
{
if (myr % 5 == 0)
Console.WriteLine
("EL NUMERO MAYOR Y MULTIPLO DE CINCO ES: " + myr);
else
Console.WriteLine("NO HAY MULTIPLOS DE CINCO");
if (mnr % 3 == 0)
{
Console.WriteLine
("EL NUMERO MENOR Y MULTIPLO DE TRES ES: " + mnr);
Console.ReadLine();
}
else
{
Console.WriteLine("NO HAY MULTIPLOS DE TRES");
Console.ReadLine();
}
}
}

19.
Leer una secuencia de letras y mostrar la suma de sus cdigos ASCII.
Suponemos que tenemos la funcin Conv_a_Codigo (char)=int.
20. Dado un vector de 5 enteros actualizar cada posicin de dicho vector
con un nmero ledo.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
namespace EJERCICIO_20
{
class Program
{
static void Main(string[] args)
{
int[] vect = new int[6];
int i = 1;
int n;

while (i < 6)
{
vect[i] = i;
Console.WriteLine
("NUMERO INGRESADO AL VECTOR EN LA POSICION: " + i);
Console.WriteLine(vect[i]);
i++;
}
Console.WriteLine("");
for (i = 1; i < 6; i++)
{
Console.WriteLine
("INGRESE EL NUEVO NUMERO PARA LA POSICION: " + i);
n = int.Parse(Console.ReadLine());
vect[i] = n;
}
Console.WriteLine("");
for (i = 1; i < 6; i++)
{
Console.WriteLine
("EL NUEVO NUMERO INGRESADO EN LA POSICION: " + i + " ES " + vect[i]);
}
Console.ReadLine();
}

21. Leer una secuencia de 20 nmeros almacenarlos en un vector y


mostrar la posicin donde se encuentra el mayor valor ledo.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_21
{
class Program
{

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
static void Main(string[] args)
{
int[] vect = new int[21];
int mayor;
int posi = 0;
for (int i = 1; i < 21; i++)
{
vect[i] = 0;
}
Console.WriteLine("Ingrese datos al vector: ");
for (int j = 1; j < 21; j++)
{
Console.Write("Posicion[" + j + "] del vector.");
vect[j] = int.Parse(Console.ReadLine());
}
mayor = vect[1];
for (int k = 1; k < 21; k++)
{
if (vect[k] >= mayor)
{
mayor = vect[k];
posi = k;
}
}
Console.WriteLine("El numero mayor es: " + mayor);
Console.WriteLine("Su posicion es: " + posi);
Console.ReadLine();
}

22.
Dado dos vectores A y B de 15 elementos cada uno, obtener un
vector C donde la posicin i se almacene la suma de A[i]+B[i].
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_22
{
class Program
{
static void Main(string[] args)
{
int[] A = new int[16];
int[] B = new int[16];
int[] sumaAB = new int[16];
int n;

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
int i;
//Para encerar lo vectores
for (i = 1; i < 16; i++)
{
A[i] = 0;
B[i] = 0;
sumaAB[i] = 0;
}
Console.WriteLine("VECTOR A");
for (i = 1; i < 16; i++)
{
Console.Write
("Ingrese un numero a la posicion[" + i + "] del vector A:");
n = int.Parse(Console.ReadLine());
A[i] = n;
}
Console.WriteLine("VECTOR B");
// para ingresar valores del vector B
for (i = 1; i < 16; i++)
{
Console.Write
("Ingrese un numero a la posicion[" + i + "] del vector B:");
n = int.Parse(Console.ReadLine());
B[i] = n;
}
for (i = 1; i < 16; i++)
{
sumaAB[i] = A[i] + B[i];
}
Console.WriteLine("RESULTADO VECTOR C");
for (i = 1; i < 16; i++)
{
Console.WriteLine
("La Suma de A y B en la posicion " + i + " es: " + sumaAB[i]);
}
Console.ReadLine();
}

23.
Dado dos vectores A y B de 15 elementos cada uno, obtener un
vector C donde la posicin i se almacene la suma de A[i]+B[i] y mostrar
el mayor de los C[i].
FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_23
{
class Program
{
static void Main(string[] args)
{
int[] A = new int[16];
int[] B = new int[16];
int[] sumaAB = new int[16];
int n;
int i;
int mayor1;
int mayor2;
//Para encerar lo vectores
for (i = 1; i < 16; i++)
{
A[i] = 0;
B[i] = 0;
sumaAB[i] = 0;
}
Console.WriteLine("VECTOR A");
for (i = 1; i < 16; i++)
{
Console.Write
("Ingrese un numero a la posicion[" + i + "] del vector A:");
n = int.Parse(Console.ReadLine());
A[i] = n;
}
Console.WriteLine("VECTOR B");
// para ingresar valores del vector B
for (i = 1; i < 16; i++)
{
Console.Write
("Ingrese un numero a la posicion[" + i + "] del vector B:");
n = int.Parse(Console.ReadLine());
B[i] = n;
}
for (i = 1; i < 16; i++)
{
sumaAB[i] = A[i] + B[i];
}
Console.WriteLine("RESULTADO VECTOR C");
for (i = 1; i < 16; i++)
{
Console.WriteLine
("La Suma de A y B en la posicion " + i + " es: " + sumaAB[i]);
}
{
if (sumaAB[1] > sumaAB[2])
{
mayor1 = sumaAB[1];
mayor2 = sumaAB[2];
}
else
{
mayor1 = sumaAB[2];
mayor2 = sumaAB[1];

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
}
for (i = 2; i < 16; i++)
{
if (sumaAB[i] > mayor1)
{
mayor2 = mayor1;
mayor1 = sumaAB[i];
}
}
Console.Write("");
Console.WriteLine("EL NUMERO MAYOR DEL RESULTADO ES: " + mayor1);
Console.ReadLine();
}
}

24.
Dado una secuencia de nmero ledos y almacenados en un vector A
mostrar dichos nmeros en orden.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICO_24
{
class Program
{
static void Main(string[] args)
{
int[] num = new int[8];
for (int a = 0; a <= 7; a++)
num[a] = 0;
for (int a = 0; a <= 7; a++)
{
Console.WriteLine("INGRESE UN NUMERO AL VECTOR");
num[a] = int.Parse(Console.ReadLine());
}
for (int a = 0; a <= 7; a++)
for (int b = a + 1; b <= 7; b++)
if (num[a] > num[b])

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
{

}
}

int aux = num[a];


num[a] = num[b];
num[b] = aux;

}
Console.WriteLine("EL VECTOR ORDENADO ES:");
for (int a = 0; a <= 7; a++)
Console.Write(num[a] + ", ");
Console.ReadLine();

25.
Leer una secuencia de 20 nmeros y almacenar en un vector sus
factoriales.
26.
Leer 20 nmeros y almacenarlos de manera ordenada en un vector.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_26
{
class Program
{
static void Main(string[] args)
{
int[] nums = new int[20];
int[] vct = new int[20];
for (int x = 0; x <= 19; x++)
nums[x] = 0;
Console.WriteLine
("INGRESE 20 NUMEROS PARA ALMACENAR Y ORDENAR EN UN VECTOR: ");
Console.WriteLine(" ");
for (int x = 0; x <= 19; x++)
{
Console.Write
("INGRESE EL NUMERO PARA LA POSICION " + x + " DEL VECTOR:");
Console.Write(" ");
nums[x] = int.Parse(Console.ReadLine());
}
for (int x = 0; x <= 19; x++)
for (int y = x + 1; y <= 19; y++)
if (nums[x] > nums[y])
{
int aux = nums[x];
nums[x] = nums[y];
nums[y] = aux;
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

}
}

Console.Write(" ");
Console.WriteLine("LOS NUMEROS EN ORDEN CRECIENTE SON:");
for (int x = 0; x <= 19; x++)
vct[x] = nums[x];
for (int x = 0; x <= 19; x++)
Console.Write(vct[x] + ", ");
Console.ReadLine();

27.
using
using
using
using

Dado dos matrices A y B obtener la suma.


System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace matriz
{
class Program
{
static void Main(string[] args)
{
//declaracin d ela matriz
int[,] mata;
int[,] matb;
int[,] matc;
int m, n;
Console.WriteLine("Cual es la dimensin de la matriz?");
Console.Write("Ingrese la primera dimensin: ");
m = Int32.Parse(Console.ReadLine());
Console.Write("Ingrese la segunda dimensin: ");
n = Int32.Parse(Console.ReadLine());
mata = new int[m, n];
matb = new int[m, n];
matc = new int[m, n];
if (m == n)
{
//encerar matriz
for (int i = 0; i < m; i++) //manejo de filas
for (int j = 0; j < n; j++) //manejo de columnas
{
mata[i, j] = 0;
matb[i, j] = 0;
matc[i, j] = 0;
}
//ingreso de datos
Console.WriteLine("Ingreso de los datos de la matriz A");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
for (int i = 0; i < m; i++) //manejo de filas
for (int j = 0; j < n; j++) //manejo de columnas
{
Console.Write("A [" + i + ", " + j + "] = ");
mata[i, j] = Int32.Parse(Console.ReadLine());
}
Console.WriteLine("Ingreso de los datos de la matriz b");
for (int i = 0; i < m; i++) //manejo de filas
for (int j = 0; j < n; j++) //manejo de columnas
{
Console.Write("B [" + i + ", " + j + "] = ");
matb[i, j] = Int32.Parse(Console.ReadLine());
}
//suma de matrices
for (int i = 0; i < m; i++) //manejo de filas
for (int j = 0; j < n; j++) //manejo de columnas
{
matc[i, j] = mata[i, j] + matb[i, j];
}
Console.WriteLine("La suma de las matrices es: ");
// Muesra d ela informacin
for (int i = 0; i < m; i++) //manejo de filas
for (int j = 0; j < n; j++) //manejo de columnas
Console.WriteLine
("C [" + i + ", " + j + "] = " + matc[i, j]);
Console.ReadLine();
}
else
{
Console.WriteLine("La matrices no son cuadrticas");
Console.ReadLine();
}
}

28.
using
using
using
using

Dado una matriz determinar la posicin (i,j) del mayor.


System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_29
{
class Program
{
static void Main(string[] args)
{
int[,] MTRZ = new int[4, 4];
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 3; Y++)

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

}
}

MTRZ[X, Y] = 0;
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 3; Y++)
{
Console.WriteLine
("INGRESAR EL VALOR [" + (X + 1) + "," + (Y + 1) + "] DE LA MATRIZ");
MTRZ[X, Y] = int.Parse(Console.ReadLine());
}
int MAY = MTRZ[1, 1];
int POSIFILA = 1;
int POSICOLUM = 1;
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 3; Y++)
{
if (MTRZ[X, Y] >= MAY)
{
MAY = MTRZ[X, Y];
POSIFILA = X + 1;
POSICOLUM = Y + 1;
}
}
Console.WriteLine("LA POSICION DEL NUMERO MAYOR DE LA MATRIZ ES:");
Console.WriteLine("[" + POSIFILA + "," + POSICOLUM + "]");
Console.WriteLine("Y EL NUMERO ES: " + MAY);
Console.ReadLine();

29.
using
using
using
using

Dado una matriz determinar la posicin (i,j) del mayor y menor.


System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_30
{
class Program
{
static void Main(string[] args)
{
int[,] MTRZ = new int[2, 2];
for (int a = 0; a <= 1; a++)
for (int b = 0; b <= 1; b++)
MTRZ[a, b] = 0;
for (int a = 0; a <= 1; a++)
for (int b = 0; b <= 1; b++)
{
Console.WriteLine
("INGRESE EL VALOR [" + (a + 1) + "," + (b + 1) + "] DE LA MATRIZ");
MTRZ[a, b] = int.Parse(Console.ReadLine());

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
}
int MAY = MTRZ[1, 1];
int POSIFIL1 = 1;
int POSICOL1 = 1;
int MEN = MTRZ[0, 0];
int POSIFIL2 = 1;
int POSICOL2 = 1;
for (int a = 0; a <= 1; a++)
for (int b = 0; b <= 1; b++)
{
if (MTRZ[a, b] >= MAY)
{
MAY = MTRZ[a, b];
POSIFIL1 = a + 1;
POSICOL1 = b + 1;
}
if (MTRZ[a, b] <= MEN)
{
MEN = MTRZ[a, b];
POSIFIL2 = a + 1;
POSICOL2 = b + 1;
}
}
Console.WriteLine(" ");
Console.WriteLine("EL MENOR NUMERO DE LA MATRIZ ES: " + MEN);
Console.WriteLine
("Y SU POSICION ES: " + "[" + POSIFIL2 + "," + POSICOL2 + "]");
Console.WriteLine(" ");
Console.WriteLine("EL MAYOR NUMERO DE LA MATRIZ ES: " + MAY);
Console.WriteLine
("Y SU POSICION ES: " + "[" + POSIFIL1 + "," + POSICOL1 + "]");
Console.ReadLine();
}

30. Leer un nmero y una letra si la letra es B mostrar el valor en binario,


si es O en octal y si es H en hexadecimal.
31. Leer una secuencia de 20 nmeros almacenarlos en un vector
A[1..20] y mostrar la suma de los elementos que ocupan posiciones
pares y el mayor de los que ocupan posiciones impares.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_31
{
class Program

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
{

static void Main(string[] args)


{
int[] vect = new int[20];
for (int n = 0; n <= 19; n++)
vect[n] = 0;
for (int n = 0; n <= 19; n++)
{
Console.Write("INGRESE EL VALOR " + (n + 1) + " DEL VECTOR: ");
vect[n] = int.Parse(Console.ReadLine());
}
int sum = 0;
int may = vect[1];
for (int n = 0; n <= 19; n++)
{
if (n % 2 != 0)
sum = sum + vect[n];
else
if (vect[n] >= may)
may = vect[n];
}
Console.WriteLine(" ");
Console.WriteLine("SUMA DE NUMEROS EN POSICIONES PARES: " + sum);
Console.WriteLine("NUMERO MAYOR EN POSICIONES IMPARES ES: " + may);
Console.ReadLine();
}

32.
using
using
using
using

Dada una matriz A[1..4][1..5] realiza la ordenacin de la misma.


System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_32
{
class Program
{
static void Main(string[] args)
{
int[,] MTRZ = new int[4, 5];
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 4; Y++)
MTRZ[X, Y] = 0;
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 4; Y++)
{
Console.Write
("INGRESE EL VALOR [" + (X + 1) + "," + (Y + 1) + "] DE LA MATRIZ: ");
MTRZ[X, Y] = int.Parse(Console.ReadLine());
}
for (int X = 0; X <= 3; X++)

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
for (int Z = 0; Z <= 3; Z++)
for (int Y = 0; Y <= 4; Y++)
for (int A = 0; A <= 4; A++)
if (MTRZ[X, Y] > MTRZ[Z, A])
{
int aux = MTRZ[X, Y];
MTRZ[X, Y] = MTRZ[Z, A];
MTRZ[Z, A] = aux;
}
Console.WriteLine(" ");
Console.WriteLine("MATRIZ ORDENADA");
for (int X = 0; X <= 3; X++)
for (int Y = 0; Y <= 4; Y++)
Console.WriteLine
("POSICION [" + (X + 1) + "," + (Y + 1) + "]=" + MTRZ[X, Y]);
Console.ReadLine();
}

33. Dada una matriz A[1..4][1..5] realiza el proceso de ordenar solo por
filas.
34. Dado un vector de nmeros determina aquellos que sea primos.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_35
{
class Program
{
static void Main(string[] args)
{
int[] NUMS = new int[5];
for (int x = 0; x <= 4; x++)
NUMS[x] = 0;
Console.WriteLine("PROGRAMA PARA ENCONTRAR NUMEROS PRIMOS");
Console.Write("");
for (int x = 0; x <= 4; x++)
{
Console.WriteLine(" INGRESE UN NUMERO PARA ALMACENARLO ");
NUMS[x] = int.Parse(Console.ReadLine());
}
Console.WriteLine("LOS NUMEROS PRIMOS ENCONTRADOS SON: ");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

}
}

for (int x = 0; x <= 4; x++)


{
int CONTADOR = 1;
int FCT = 1;
if (NUMS[x] >= 1)
{
do
{
FCT = FCT * CONTADOR;
CONTADOR++;
}
while (CONTADOR < NUMS[x]);
if ((FCT + 1) % NUMS[x] == 0)
Console.WriteLine(NUMS[x]);
}
}
Console.ReadLine();

35. Dado una secuencia de nmeros determinar el mayor ledo y el


nmero de veces que aparece.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_35
{
class Program
{
static void Main(string[] args)
{
int[] scncia = new int[10];
Console.WriteLine
("INGRESE EL NUMERO QUE DESEA VER LAS VECES Q APARECE EN EL
VECTOR:");
int n = int.Parse(Console.ReadLine());
Console.WriteLine(" ");
for (int x = 0; x <= 9; x++)
scncia[x] = 0;
for (int x = 0; x <= 9; x++)
{
Console.WriteLine("INGRESE NUMEROS AL VECTOR");
scncia[x] = int.Parse(Console.ReadLine());
}
int contador = 0;
for (int x = 0; x <= 9; x++)
{

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
if (n == scncia[x])
contador++;

}
}

}
Console.WriteLine(" ");
Console.WriteLine
("SU NUMERO APARECE " +contador + " VECES EN EL VECTOR");
Console.ReadLine();

36. Dado una secuencia de palabras determinar el mayor y menor


lexicogrficamente.
37. Resolucin de una ecuacin de 2 grado.
38. Disee un algoritmo que determine la suma de las cifras de un
nmero entero positivo de cuatro cifras. Considerando que el nmero
tiene 4 cifras, se podra obtener las cifras por divisiones sucesivas entre
1000, 100, y 10.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_38
{
class Program
{
static void Main(string[] args)
{
int n, mil, dec, cent, uni, rest, suma;
Console.WriteLine("Ingrese un numero de 4 cifras");
n = Int32.Parse(Console.ReadLine());
mil = n / 1000;
rest = n % 1000;
cent = rest / 100;
rest = rest % 100;
dec = rest / 10;
uni = rest % 10;
suma = mil + cent + dec + uni;
Console.WriteLine("La suma de las cifras del numero es " + suma);
Console.ReadLine();
}

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
39. Disee un algoritmo que lea la hora actual del da en formato
HHMMSS y determine cuantas HHMMSS restan para culminar el da.
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_39
{
class Program
{
static void Main(string[] args)
{
int h1, m1, s1, h2, m2, s2, rest, segr;
Console.WriteLine("Ingrese la hora");
h1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los minutos");
m1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los segundos");
s1 = Int32.Parse(Console.ReadLine());
segr = 86400 - (h1 * 3600 + m1 * 60 + s1);
h2 = segr / 3600;
rest = segr % 3600;
m2 = rest / 60;
s2 = rest % 60;
Console.WriteLine("El tiempo para que culmine el dia es:");
Console.WriteLine("" + h2 + " , " + m2 + " , " + s2);
Console.ReadLine();
}
}
}

40. Disee un algoritmo para sumar dos tiempos dados en HHMMSS


using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_40
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("
ADICION DE HORAS
");
Console.WriteLine("Ingresando los datos de la primera");
int h1, m1, s1, h2, m2, s2, h3, m3, s3, tots, rest;
Console.WriteLine("");
Console.WriteLine("Ingrese la hora");
h1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los minutos");
m1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los segundos");
s1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

}
}

Console.WriteLine("Ingresando los datos de la segunda");


Console.WriteLine("");
Console.WriteLine("Ingrese la hora");
h2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los minutos");
m2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los segundos");
s2 = Int32.Parse(Console.ReadLine());
tots = (h1 + h2) * 3600 + (m1 + m2) * 60 + (s1 + s2);
h3 = tots / 3600;
rest = tots % 3600;
m3 = rest / 60;
s3 = rest % 60;
Console.WriteLine("");
Console.WriteLine("La suma de las 2 horas es:");
Console.WriteLine(""+h3+" + "+m3+" + "+s3+"");
Console.ReadLine();

41. El sueldo neto de un vendedor se calcula como la suma de un sueldo

bsico de 250,00 dlares ms el 12 % del monto total vendido. Disee


un algoritmo que determine el sueldo neto de un vendedor sabiendo que
hizo tres ventas en el mes
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_41
{
class Program
{
static void Main(string[] args)
{
double v1, v2, v3, vtot, com, sueldonet;
Console.WriteLine("CALCULO DEL SUELDO NETO DE UN VENDEDOR");
Console.WriteLine("");
Console.WriteLine("Ingrese el valor de las ventas");
Console.WriteLine("");
Console.WriteLine("VENTA 1");
v1 = double.Parse(Console.ReadLine());
Console.WriteLine("VENTA 2");
v2 = double.Parse(Console.ReadLine());
Console.WriteLine("VENTA 3");
v3 = double.Parse(Console.ReadLine());
vtot = v1 + v2 + v3;
com = 0.12 * vtot;
sueldonet = (double)250.00 + com;
Console.WriteLine("");
Console.WriteLine("El sueldo neto del vendevor es " + sueldonet);

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
Console.ReadLine();
}

42. Disee un algoritmo que determine el porcentaje de varones y mujeres

que hay en un saln de clases.


using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICIO_42
{
class Program
{
static void Main(string[] args)
{
double porcvar, porcemuj;
int muj, var, total;
Console.Write("Ingrese el numero de votos de mujeres: ");
muj = Int32.Parse(Console.ReadLine());
Console.Write("Ingrese el numero de votos de hombres: ");
var = Int32.Parse(Console.ReadLine());
total = var + muj;
porcemuj = (double)muj * 100 / total;
porcvar = (double)var * 100 / total;
Console.WriteLine("");
Console.WriteLine("El porcentaje masculino es: " + porcvar);
Console.WriteLine("El porcentaje femenino es: " + porcemuj);
Console.ReadLine();
}
}

43. Disee un algoritmo para obtener el grado de eficiencia de un operario

de una fbrica de tornillos, de acuerdo a las siguientes condiciones, que


se le imponen para un periodo de prueba:
Menos de 200 tornillos defectuosos.
Ms de 100000 tornillos producidos.
El grado de eficiencia se determina de la siguiente manera:
Si no cumple ninguna de las condiciones, grado 5.
Si solo cumple la primera condicin, grado 6.
Si solo cumple la segunda condicin, grado 7.
Si cumple las dos condiciones, grado 8.
class Program
{
static void Main(string[] args)

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
{

}
}

int grado, tordefec, torprodu;


Console.WriteLine("Ingrese el numero de tornillos defectuosos");
tordefec = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese el numero de tornilos producidos");
torprodu = Int32.Parse(Console.ReadLine());
if (torprodu > 100000 & tordefec < 200)
{
grado = 8;
}
else
{
if (torprodu > 100000)
{
grado = 7;
}
else
{
if (tordefec > 200)
{
grado = 6;
}
else
{
grado = 5;
}
}
}
Console.WriteLine("");
Console.WriteLine("El grado de eficiencia es " + grado);
Console.ReadLine();

44. Se cuenta con los votos obtenidos por Juan, Pedro y Mara en una

eleccin democrtica a la presencia de un club. Para ganar la eleccin se


debe obtener como mnimo 50% de los votos ms 1. En caso que en
caso que no haya un ganador se repite la elecciones una segunda vuelta.
Van a la segunda vuelta los dos que obtengan la ms alta votacin o, los
tres en caso de producirse un empate doble (entre los dos con menor
votacin) o un empate triple. Disee un algoritmo que determine el
resultado de la eleccin
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace EJERCICO_44
{
class Program
{
static void Main(string[] args)
{
int a, b, c, vmax, vt;
Console.WriteLine(" CONTEO AUTOMATICO DE VOTOS ");
Console.WriteLine("");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA
Console.WriteLine("Ingrese los votos de Juan ");
a = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los votos de Pedro");
b = Int32.Parse(Console.ReadLine());
Console.WriteLine("Ingrese los votos de Maria");
c = Int32.Parse(Console.ReadLine());
Console.WriteLine("");
vt = a + b + c;
vmax = a;
if (b > vmax)
vmax = b;
if (c > vmax)
vmax = c;
if (vmax > vt / 2)
{
if (a == vmax)
{
Console.WriteLine("El ganador es Juan");
}
else
{
if (b == vmax)
{
Console.WriteLine("El ganador es Pedro");
}
else
{
Console.WriteLine("El gandor es Maria");
}
}
}
else
{
if (a < b & a < c)
{
Console.WriteLine("Debe haber segunda vuelta entre
}
else
{
if (b < a & b < c)
{
Console.WriteLine("Debe haber segunda vuelta entre
}
else
{
if (c < a & c < b)
{
Console.WriteLine("Debe haber segunda vuelta entre
}
else
{
Console.WriteLine("Debe haber segunda vuelta entre
}
}
}
}
Console.ReadLine();
}

Pedro y Maria");

Juan y Maria");

Juan y Maria");

los tres");

FREDDY GUZMAN ALARCON

02-FEB-2012

UNIVERSIDAD CENTRAL DEL ECUADOR


FACULTAD DE INGENIERIA EN CIENCIAS FISICAS Y MATEMATICA

FREDDY GUZMAN ALARCON

02-FEB-2012

Anda mungkin juga menyukai