Vous êtes sur la page 1sur 56

- Estructura de programacin secuencial

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

namespace PerimetroCuadrado { class Program { static void Main(string[] args) { int lado,perimetro; string linea; Console.Write("Ingrese el lado del cuadrado:"); linea=Console.ReadLine(); lado=int.Parse(linea); perimetro=lado * 4; Console.Write("El permetro del cuadrado es:"); Console.Write(perimetro); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace SumaProductos4Numeros { class Program { static void Main(string[] args) { int num1,num2,num3,num4,suma,producto; string linea; Console.Write("Ingrese primer valor:"); linea=Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea=Console.ReadLine(); num2=int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea=Console.ReadLine(); num3=int.Parse(linea); Console.Write("Ingrese cuarto valor:"); linea=Console.ReadLine(); num4=int.Parse(linea); suma=num1 + num2; producto=num3 * num4; Console.Write("La suma de los dos primero valores es:"); Console.WriteLine(suma); Console.Write("El producto del tercer y cuarto valor es:");

Console.Write(producto); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace SumaPromedio { class Program { static void Main(string[] args) { int num1,num2,num3,num4,suma,promedio; string linea; Console.Write("Ingrese primer valor:"); linea=Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea=Console.ReadLine(); num2=int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea=Console.ReadLine(); num3=int.Parse(linea); Console.Write("Ingrese cuarto valor:"); linea=Console.ReadLine(); num4=int.Parse(linea); suma=num1 + num2 + num3 + num4; promedio=suma/4; Console.Write("La suma de los cuatro valores es:"); Console.WriteLine(suma); Console.Write("El promedio es:"); Console.Write(promedio); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CostoCompra { class Program { static void Main(string[] args) { int cantidad; float precio,importe; string linea; Console.Write("Ingrese la cantidad de artculos a llevar:");

linea=Console.ReadLine(); cantidad=int.Parse(linea); Console.Write("Ingrese el valor unitario del producto:"); linea=Console.ReadLine(); precio=float.Parse(linea); importe=precio * cantidad; Console.Write("El importe total a pagar es:"); Console.Write(importe); Console.ReadKey(); } } }

- Estructuras condicionales simples y compuestas


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

namespace EstructuraCondicionalCompuesta2 { class Program { static void Main(string[] args) { int num1,num2; string linea; Console.Write("Ingrese primer valor:"); linea=Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea=Console.ReadLine(); num2=int.Parse(linea); if (num1>num2) { int suma,diferencia; suma=num1 + num2; diferencia=num1 - num2; Console.Write("La suma de los dos valores es:"); Console.WriteLine(suma); Console.Write("La diferencia de los dos valores es:"); Console.WriteLine(diferencia); } else { int producto,division; producto=num1 * num2; division=num1 / num2; Console.Write("El producto de los dos valores es:"); Console.WriteLine(producto); Console.Write("La divisin de los dos valores es:"); Console.WriteLine(division); } Console.ReadKey();

} } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraCondicionalSimple2 { class Program { static void Main(string[] args) { int nota1,nota2,nota3; string linea; Console.Write("Ingrese primer nota:"); linea=Console.ReadLine(); nota1=int.Parse(linea); Console.Write("Ingrese segunda nota:"); linea=Console.ReadLine(); nota2=int.Parse(linea); Console.Write("Ingrese tercer nota:"); linea=Console.ReadLine(); nota3=int.Parse(linea); int promedio; promedio=(nota1 + nota2 + nota3) / 3; if (promedio>=7) { Console.Write("Promocionado"); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraCondicionalCompuesta3 { class Program { static void Main(string[] args) { int num; string linea; Console.Write("Ingrese un valor entero de 1 o 2 dgitos:"); linea=Console.ReadLine(); num=int.Parse(linea); if (num<10) { Console.Write("Tiene un dgito"); }

else { Console.Write("Tiene dos dgitos"); } Console.ReadKey(); } } }

- Estructuras condicionales anidadas


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

namespace EstructuraCondicionalAnidada2 { class Program { static void Main(string[] args) { int num1,num2,num3; string linea; Console.Write("Ingrese primer valor:"); linea = Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segunda valor:"); linea = Console.ReadLine(); num2 = int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea = Console.ReadLine(); num3 = int.Parse(linea); if (num1>num2) { if (num1>num3) { Console.Write(num1); } else { Console.Write(num3); } } else { if (num2>num3) { Console.Write(num2); } else { Console.Write(num3); } }

Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraCondicionalAnidada3 { class Program { static void Main(string[] args) { int num; string linea; Console.Write("Ingrese un valor:"); linea = Console.ReadLine(); num=int.Parse(linea); if (num==0) { Console.Write("Se ingres el cero"); } else { if (num>0) { Console.Write("Se ingres un valor positivo"); } else { Console.Write("Se ingres un valor negativo"); } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraCondicionalAnidada4 { class Program { static void Main(string[] args) { int num; string linea; Console.Write("Ingrese un valor de hasta tres dgitos positivo:"); linea = Console.ReadLine();

num=int.Parse(linea); if (num<10) { Console.Write("Tiene un dgito"); } else { if (num<100) { Console.Write("Tiene dos dgitos"); } else { if (num<1000) { Console.Write("Tiene tres dgitos"); } else { Console.Write("Error en la entrada de datos."); } } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraCondicionalAnidada4 { class Program { static void Main(string[] args) { int totalPreguntas,totalCorrectas; string linea; Console.Write("Ingrese la cantidad total de preguntas del examen:"); linea = Console.ReadLine(); totalPreguntas=int.Parse(linea); Console.Write("Ingrese la cantidad total de preguntas contestadas correctamente:"); linea = Console.ReadLine(); totalCorrectas=int.Parse(linea); int porcentaje=totalCorrectas * 100 / totalPreguntas; if (porcentaje>=90) { Console.Write("Nivel mximo"); } else { if (porcentaje>=75)

{ Console.Write("Nivel medio"); } else { if (porcentaje>=50) { Console.Write("Nivel regular"); } else { Console.Write("Fuera de nivel"); } } } Console.ReadKey(); } } }

- Condiciones compuestas con operadores lgicos


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

namespace CondicionesCompuestas3 { class Program { static void Main(string[] args) { int dia,mes,ao; string linea; Console.Write("Ingrese nro de da:"); linea = Console.ReadLine(); dia=int.Parse(linea); Console.Write("Ingrese nro de mes:"); linea = Console.ReadLine(); mes=int.Parse(linea); Console.Write("Ingrese nro de ao:"); linea = Console.ReadLine(); ao = int.Parse(linea); if (mes==12 && dia==25) { Console.Write("La fecha ingresada corresponde a navidad."); } Console.ReadKey(); } } }

using using using using

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

namespace CondicionesCompuestas4 { class Program { static void Main(string[] args) { int num1,num2,num3; string linea; Console.Write("Ingrese primer valor:"); linea = Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea = Console.ReadLine(); num2 = int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea = Console.ReadLine(); num3 = int.Parse(linea); if (num1==num2 && num1==num3) { int suma=num1 + num2; Console.Write("La suma del primero y segundo:"); Console.WriteLine(suma); int producto=suma * num3; Console.Write("La suma del primero y segundo multiplicado por el tercero:"); Console.Write(producto); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CondicionesCompuestas5 { class Program { static void Main(string[] args) { int num1,num2,num3; string linea; Console.Write("Ingrese primer valor:"); linea=Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea=Console.ReadLine(); num2=int.Parse(linea); Console.Write("Ingrese tercer valor:");

linea=Console.ReadLine(); num3=int.Parse(linea); if (num1<10 && num2<10 && num3<10) { Console.Write("Todos los nmeros son menores a diez"); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CondicionesCompuestas6 { class Program { static void Main(string[] args) { int num1,num2,num3; string linea; Console.Write("Ingrese primer valor:"); linea = Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea = Console.ReadLine(); num2 = int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea = Console.ReadLine(); num3 = int.Parse(linea); if (num1<10 || num2<10 || num3<10) { Console.Write("Alguno de los nmeros es menor a diez"); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CondicionesCompuestas7 { class Program { static void Main(string[] args) { int x, y; string linea; Console.Write("Ingrese coordenada x:"); linea = Console.ReadLine();

x = int.Parse(linea); Console.Write("Ingrese coordenada y:"); linea = Console.ReadLine(); y = int.Parse(linea); if (x > 0 && y > 0) { Console.Write("Se encuentra en el primer cuadrante"); } else { if (x < 0 && y > 0) { Console.Write("Se encuentra en el segundo cuadrante"); } else { if (x < 0 && y < 0) { Console.Write("Se encuentra en el tercer cuadrante"); } else { Console.Write("Se encuentra en el cuarto cuadrante"); } } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CondicionesCompuestas8 { class Program { static void Main(string[] args) { float sueldo; int antiguedad; string linea; Console.Write("Ingrese sueldo del empleado:"); linea = Console.ReadLine(); sueldo=float.Parse(linea); Console.Write("Ingrese su antiguedad en aos:"); linea = Console.ReadLine(); antiguedad=int.Parse(linea); if (sueldo<500 && antiguedad>10) { float aumento=sueldo * 0.20f;

float sueldoTotal=sueldo+aumento; Console.Write("Sueldo a pagar:"); Console.Write(sueldoTotal); } else { if (sueldo<500) { float aumento=sueldo * 0.05f; float sueldoTotal=sueldo+aumento; Console.Write("Sueldo a pagar:"); Console.Write(sueldoTotal); } else { Console.Write("Sueldo a pagar:"); Console.Write(sueldo); } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace CondicionesCompuestas9 { class Program { static void Main(string[] args) { int num1,num2,num3; string linea; Console.Write("Ingrese primer valor:"); linea = Console.ReadLine(); num1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea = Console.ReadLine(); num2 = int.Parse(linea); Console.Write("Ingrese tercer valor:"); linea = Console.ReadLine(); num3 = int.Parse(linea); Console.Write("Rango de valores:"); if (num1num2 && num1>num3) { Console.Write(num1); } else { if (num2>num3) { Console.Write(num2); }

else { Console.Write(num3); } } Console.ReadKey(); } } }

- Estructura repetitiva while


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

namespace EstructuraRepetitivaWhile5 { class Program { static void Main(string[] args) { int x,nota,conta1,conta2; string linea; x=1; conta1=0; conta2=0; while (x<=10) { Console.Write("Ingrese nota:"); linea = Console.ReadLine(); nota=int.Parse(linea); if (nota>=7) { conta1=conta1 + 1; } else { conta2=conta2 + 1; } x=x + 1; } Console.Write("Cantidad de alumnos con notas mayores o iguales a 7:"); Console.WriteLine(conta1); Console.Write("Cantidad de alumons con notas menores a 7:"); Console.Write(conta2); Console.ReadKey(); } } } using System; using System.Collections.Generic; using System.Linq;

using System.Text; namespace EstructuraRepetitivaWhile6 { class Program { static void Main(string[] args) { int n,x; float altura,suma,promedio; string linea; Console.Write("Cuantas personas hay:"); linea = Console.ReadLine(); n=int.Parse(linea); x=1; suma=0; while (x<=n) { Console.Write("Ingrese la altura:"); linea = Console.ReadLine(); altura=float.Parse(linea); suma=suma + altura; x=x + 1; } promedio=suma/n; Console.Write("Altura promedio:"); Console.Write(promedio); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaWhile7 { class Program { static void Main(string[] args) { int n,x,conta1,conta2; float sueldo,gastos; string linea; Console.Write("Cuantos empleados tiene la empresa:"); linea = Console.ReadLine(); n=int.Parse(linea); x=1; conta1=0; conta2=0; gastos=0; while (x<=n) { Console.Write("Ingrese el sueldo del empleado:"); linea = Console.ReadLine(); sueldo=float.Parse(linea);

if (sueldo<=300) { conta1=conta1 + 1; } else { conta2=conta2 + 1; } gastos=gastos+sueldo; x=x + 1; } Console.Write("Cantidad de empleados con sueldos entre 100 y 300:"); Console.WriteLine(conta1); Console.Write("Cantidad de empleados con sueldos mayor a 300:"); Console.WriteLine(conta2); Console.Write("Gastos total de la empresa en sueldos:"); Console.WriteLine(gastos); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaWhile8 { class Program { static void Main(string[] args) { int x,termino; x=1; termino=11; while (x<=25) { Console.Write(termino); Console.Write(" - "); x=x + 1; termino=termino + 11; } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaWhile9 { class Program { static void Main(string[] args)

{ int mult8; mult8=8; while (mult8<=500) { Console.Write(mult8); Console.Write(" - "); mult8=mult8 + 8; } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaWhile10 { class Program { static void Main(string[] args) { int valor,x,suma1,suma2; string linea; x=1; suma1=0; suma2=0; Console.Write("Primer lista"); while (x<=15) { Console.Write("Ingrese valor:"); linea = Console.ReadLine(); valor=int.Parse(linea); suma1=suma1 + valor; x=x + 1; } Console.Write("Segunda lista"); x=1; while (x<=15) { Console.Write("Ingrese valor:"); linea = Console.ReadLine(); valor=int.Parse(linea); suma2=suma2 + valor; x=x + 1; } if (suma1>suma2) { Console.Write("Lista 1 mayor."); } else { if (suma2>suma1) {

Console.Write("Lista2 mayor."); } else { Console.Write("Listas iguales."); } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaWhile11 { class Program { static void Main(string[] args) { int n,x,valor,pares,impares; string linea; x=1; pares=0; impares=0; Console.Write("Cuantos nmeros ingresar:"); linea = Console.ReadLine(); n=int.Parse(linea); while (x<=n) { Console.Write("Ingrese el valor:"); linea = Console.ReadLine(); valor = int.Parse(linea); ; if (valor%2==0) { pares=pares + 1; } else { impares=impares + 1; } x=x + 1; } Console.Write("Cantadad de pares:"); Console.WriteLine(pares); Console.Write("Cantidad de impares:"); Console.Write(impares); Console.ReadKey(); } } }

- Estructura repetitiva for


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

namespace EstructuraRepetitivaFor6 { class Program { static void Main(string[] args) { int basetri,altura,superficie,cantidad,f,n; string linea; cantidad=0; Console.Write("Cuantos tringulos procesar:"); linea = Console.ReadLine(); n=int.Parse(linea); for(f=1;f<=n;f++) { Console.Write("Ingrese el valor de la base:"); linea = Console.ReadLine(); basetri=int.Parse(linea); Console.Write("Ingrese el valor de la altura:"); linea = Console.ReadLine(); altura=int.Parse(linea); superficie=basetri*altura/2; Console.Write("La superficie es:"); Console.WriteLine(superficie); if (superficie>12) { cantidad=cantidad+1; } } Console.Write("La cantidad de tringulos con superficie superior a 12 son:"); Console.Write(cantidad); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor7 { class Program { static void Main(string[] args) { int f,valor,suma;

string linea; suma=0; for(f=1;f<=10;f++) { Console.Write("Ingrese un valor:"); linea = Console.ReadLine(); valor=int.Parse(linea); if (f>5) { suma=suma+valor; } } Console.Write("La suma de los ltimos 5 valores es:"); Console.Write(suma); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor8 { class Program { static void Main(string[] args) { int f; for(f=5;f<=50;f=f+5) { Console.Write(f); Console.Write("-"); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor9 { class Program { static void Main(string[] args) { int f,valor; string linea; Console.Write("Ingrese un valor entre 1 y 10:"); linea = Console.ReadLine(); valor=int.Parse(linea);

for(f=valor;f<=valor*12;f=f+valor) { Console.Write(f); Console.Write("-"); } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor10 { class Program { static void Main(string[] args) { int f,lado1,lado2,lado3,cant1,cant2,cant3,n; string linea; cant1=0; cant2=0; cant3=0; Console.Write("Ingrese la cantidad de tringulos:"); linea = Console.ReadLine(); n=int.Parse(linea); for(f=1;f<=n;f++) { Console.Write("Ingrese lado 1:"); linea = Console.ReadLine(); lado1=int.Parse(linea); Console.Write("Ingrese lado 2:"); linea = Console.ReadLine(); lado2 = int.Parse(linea); Console.Write("Ingrese lado 3:"); linea = Console.ReadLine(); lado3 = int.Parse(linea); if (lado1==lado2 && lado1==lado3) { Console.WriteLine("Es un tringulo equilatero."); cant1++; } else { if (lado1==lado2 || lado1==lado3 || lado2==lado3) { Console.WriteLine("Es un tringulo issceles."); cant2++; } else { cant3++; Console.WriteLine("Es un tringulo escaleno."); }

} } Console.Write("Cantidad de tringulos equilateros:"); Console.WriteLine(cant1); Console.Write("Cantidad de tringulos issceles:"); Console.WriteLine(cant2); Console.Write("Cantidad de tringulos escalenos:"); Console.WriteLine(cant3); if (cant1<cant2 && cant1<cant3) { Console.Write("Hay menor cantidad de tringulos equilateros."); } else { if (cant2<cant3) { Console.Write("Han menor cantidad de tringulos issceles"); } else { Console.Write("Han menor cantidad de tringulos escalenos"); } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor11 { class Program { static void Main(string[] args) { int n,f,x,y,cant1,cant2,cant3,cant4; string linea; cant1=0; cant2=0; cant3=0; cant4=0; Console.Write("Cantidad de puntos:"); linea = Console.ReadLine(); n=int.Parse(linea); for(f=1;f<=n;f++) { Console.Write("Ingrese coordenada x:"); linea = Console.ReadLine(); x=int.Parse(linea); Console.Write("Ingrese coordenada y:");

linea = Console.ReadLine(); y=int.Parse(linea); if (x>0 && y>0) { cant1++; } else { if (x<0 && y>0) { cant2++; } else { if (x<0 && y<0) { cant3++; } else { if (x>0 && y<0) { cant4++; } } } } } Console.Write("Cantidad de Console.WriteLine(cant1); Console.Write("Cantidad de Console.WriteLine(cant2); Console.Write("Cantidad de Console.WriteLine(cant3); Console.Write("Cantidad de Console.WriteLine(cant4); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text; puntos en el primer cuadrante:"); puntos en el segundo cuadrante:"); puntos en el tercer cuadrante:"); puntos en el cuarto cuadrante:");

namespace EstructuraRepetitivaFor12 { class Program { static void Main(string[] args) { int f,valor,negativos,positivos,mult15,sumapares; string linea; negativos=0; positivos=0; mult15=0;

sumapares=0; for(f=1;f<=10;f++) { Console.Write("Ingrese valor:"); linea = Console.ReadLine(); valor=int.Parse(linea); if (valor<0) { negativos++; } else { if (valor>0) { positivos++; } } if (valor%15==0) { mult15++; } if (valor%2==0) { sumapares=sumapares+valor; } } Console.Write("Cantidad de valores negativos:"); Console.WriteLine(negativos); Console.Write("Cantidad de valores positivos:"); Console.WriteLine(positivos); Console.Write("Cantidad de valores mltiplos de 15:"); Console.WriteLine(mult15); Console.Write("Suma de los valores pares:"); Console.WriteLine(sumapares); Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaFor13 { class Program { static void Main(string[] args) { int f,edad,suma1,suma2,suma3,pro1,pro2,pro3; string linea; suma1=0; suma2=0; suma3=0; for(f=1;f<=50;f++) { Console.Write("Ingrese edad:");

linea = Console.ReadLine(); edad=int.Parse(linea); suma1=suma1+edad; } pro1=suma1/50; Console.Write("Promedio de edades del turno Console.WriteLine(pro1); for(f=1;f<=60;f++) { Console.Write("Ingrese edad:"); linea = Console.ReadLine(); edad = int.Parse(linea) ; suma2=suma2+edad; } pro2=suma2/60; Console.Write("Promedio de edades del turno Console.WriteLine(pro2); for(f=1;f<=110;f++) { Console.Write("Ingrese edad:"); linea = Console.ReadLine(); edad=int.Parse(linea); suma3=suma3+edad; } pro3=suma3/110; Console.Write("Promedio de edades del turno Console.WriteLine(pro3); if (pro1<pro2 && pro1<pro3) { Console.Write("El turno maana tiene un edades."); } else { if (pro2<pro3) { Console.Write("El turno tarde tiene un promedio menor de edades."); } else { Console.Write("El turno noche tiene un promedio menor de edades."); } } Console.ReadKey(); } } } maana:");

tarde:");

noche:");

promedio menor de

- Estructura repetitiva do while


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

namespace EstructuraRepetitivaDoWhile4 { class Program { static void Main(string[] args) { int suma,valor; string linea; suma=0; do { Console.Write("Ingrese un valor:"); linea = Console.ReadLine(); valor=int.Parse(linea); if (valor!=9999) { suma=suma+valor; } }while (valor!=9999); Console.Write("El valor acumulado es "); Console.WriteLine(suma); if (suma==0) { Console.WriteLine("El valor acumulado es cero."); } else { if (suma>0) { Console.WriteLine("El valor acumulado es positivo."); } else { Console.WriteLine("El valor acumulado es negativo"); } } Console.ReadKey(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace EstructuraRepetitivaDoWhile5 {

class Program { static void Main(string[] args) { int cuenta; float saldo,suma; string linea; suma=0; do { Console.Write("Ingrese nmero de cuenta:"); linea = Console.ReadLine(); cuenta=int.Parse(linea); if (cuenta>=0) { Console.Write("Ingrese saldo:"); linea = Console.ReadLine(); saldo=float.Parse(linea); if (saldo>0) { Console.WriteLine("Saldo Acreedor."); suma=suma+saldo; } else { if (saldo<0) { Console.WriteLine("Saldo Deudor."); } else { Console.WriteLine("Saldo Nulo."); } } } } while(cuenta>=0); Console.Write("Total de saldos Acreedores:"); Console.Write(suma); Console.ReadKey(); } } }

- Declaracin de una clase y definicin de objetos.


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

namespace PruebaClase5 { class Empleado { string nombre; float sueldo;

public void Inicializar() { string linea; Console.Write("Ingrese el nombre del empleado:"); nombre = Console.ReadLine(); Console.Write("Ingrese su sueldo:"); linea = Console.ReadLine(); sueldo=float.Parse(linea); } public void PagaImpuestos() { if (sueldo>3000) { Console.WriteLine("Debe abonar impuestos"); } else { Console.WriteLine("No paga impuestos"); } Console.ReadKey(); } static void Main(string[] args) { Empleado empleado1= new Empleado(); empleado1.Inicializar(); empleado1.PagaImpuestos(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaClase5 { class Operaciones { private int valor1, valor2; public void Inicializar() { string linea; Console.Write("Ingrese primer valor:"); linea=Console.ReadLine(); valor1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea = Console.ReadLine(); valor2=int.Parse(linea); } public void Sumar() {

int suma; suma=valor1+valor2; Console.WriteLine("La suma es:"+suma); } public void Restar() { int resta; resta=valor1-valor2; Console.WriteLine("La resta es:"+resta); } public void Multiplicar() { int multiplicacion; multiplicacion=valor1*valor2; Console.WriteLine("La multiplicacin es:"+multiplicacion); } public void dividir() { int division; division = valor1 / valor2; Console.WriteLine("La divisin es:" + division); } static void Main(string[] args) { Operaciones operacion1 = new Operaciones(); operacion1.Inicializar(); operacion1.Sumar(); operacion1.Restar(); operacion1.Multiplicar(); operacion1.dividir(); Console.ReadKey(); } } }

- Estructura de datos tipo vector


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

namespace PruebaVector4 { class PruebaVector4 { private int[] vec; public void Cargar() {

vec=new int[8]; for(int f = 0; f < 8; f++) { Console.Write("Ingrese elemento:"); string linea; linea = Console.ReadLine(); vec[f]=int.Parse(linea); } } public void AcumularElementos() { int suma=0; for(int f = 0; f < 8; f++) { suma=suma+vec[f]; } Console.WriteLine("La suma de los 8 elementos es:"+suma); } public void AcumularMayores36() { int suma=0; for(int f = 0; f < 8; f++) { if (vec[f] > 36) { suma=suma+vec[f]; } } Console.WriteLine("La suma de los elementos mayores a 36 es:"+suma); } public void CantidadMayores50() { int cant=0; for(int f = 0; f < 8; f++) { if (vec[f] > 50) { cant++; } } Console.WriteLine("La cantidad de valores mayores a 50 es:"+cant); Console.ReadKey(); } static void Main(string[] args) { PruebaVector4 pv = new PruebaVector4(); pv.Cargar(); pv.AcumularElementos(); pv.AcumularMayores36(); pv.CantidadMayores50(); }

} } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaVector5 { class PruebaVector5 { private int[] vec1; private int[] vec2; private int[] vecSuma; public void Cargar() { vec1=new int[4]; vec2=new int[4]; Console.WriteLine("Carga del primer vector."); for(int f = 0;f < 4; f++) { Console.Write("Ingrese elemento:"); string linea; linea=Console.ReadLine(); vec1[f]=int.Parse(linea); } Console.WriteLine("Carga del segundo vector."); for(int f = 0; f < 4; f++) { Console.Write("Ingrese elemento:"); string linea; linea = Console.ReadLine(); vec2[f] = int.Parse(linea); } } public void SumarizarVectores() { vecSuma=new int[4]; for(int f = 0;f < 4; f++) { vecSuma[f]=vec1[f]+vec2[f]; } Console.WriteLine("Vector resultante."); for(int f = 0; f < 4; f++) { Console.WriteLine(vecSuma[f]); } Console.ReadKey(); } static void Main(string[] args) { PruebaVector5 pv = new PruebaVector5(); pv.Cargar();

pv.SumarizarVectores(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaVector6 { class PruebaVector6 { private int[] cursoa; private int[] cursob; private int[] vecSuma; public void Cargar() { cursoa=new int[5]; cursob=new int[5]; Console.WriteLine("Carga de notas del curso A"); for(int f = 0; f < 5; f++) { Console.Write("Ingrese nota:"); string linea; linea = Console.ReadLine(); cursoa[f]=int.Parse(linea); } Console.WriteLine("Carga del notas del curso B"); for(int f = 0; f < 5; f++) { Console.Write("Ingrese nota:"); string linea; linea = Console.ReadLine(); cursob[f] =int.Parse(linea); } } public void CalcularPromedios() { int suma1=0; int suma2=0; for(int f=0;f<5;f++) { suma1=suma1+cursoa[f]; suma2=suma2+cursob[f]; } int promedioa=suma1/5; int promediob=suma2/5; if (promedioa>promediob) { Console.WriteLine("El curso A tiene un promedio mayor."); } else {

Console.WriteLine("El curso B tiene un promedio mayor."); } Console.ReadKey(); } static void Main(string[] args) { PruebaVector6 pv = new PruebaVector6(); pv.Cargar(); pv.CalcularPromedios(); } } } using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaVector7 { class PruebaVector7 { private int[] vec; public void Cargar() { vec=new int[10]; for(int f = 0; f < 10; f++) { Console.Write("Ingrese elemento:"); string linea = Console.ReadLine(); vec[f]=int.Parse(linea); } } public void VerificarOrdenado() { int orden=1; for(int f = 0; f < 9; f++) { if (vec[f+1] < vec[f]) { orden=0; } } if (orden==1) { Console.WriteLine("Esta ordenado de menor a mayor"); } else { Console.WriteLine("No esta ordenado de menor a mayor"); } Console.ReadKey(); }

static void Main(string[] args) { PruebaVector7 pv = new PruebaVector7(); pv.Cargar(); pv.VerificarOrdenado(); } } }

- Vector (Tamao de un vector)


using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PruebaVector9 { class PruebaVector9 { private int[] vec; public void Cargar() { Console.Write("Cuantos elementos tiene el vector:"); string linea=Console.ReadLine(); int n; n=int.Parse(linea); vec=new int[n]; for(int f = 0; f < vec.Length; f++) { Console.Write("Ingrese elemento:"); linea=Console.ReadLine(); vec[f]=int.Parse(linea); } } public void AcumularElementos() { int suma=0; for(int f = 0; f < vec.Length; f++) { suma=suma+vec[f]; } Console.WriteLine("La suma de los elementos es:"+suma); Console.ReadKey(); } static void Main(string[] args) { PruebaVector9 pv = new PruebaVector9(); pv.Cargar(); pv.AcumularElementos(); } } }

- Vectores (mayor y menor elemento)


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

namespace PruebaVector12 { class PruebaVector12 { private int[] vec; private int menor; public void Cargar() { Console.Write("Cuantos elementos desea cargar:"); string linea; linea = Console.ReadLine(); int n=int.Parse(linea); vec=new int[n]; for(int f=0;f < vec.Length;f++) { Console.Write("Ingrese componente:"); linea = Console.ReadLine(); vec[f]=int.Parse(linea); } } public void MenorElemento() { menor=vec[0]; for(int f=1;f < vec.Length;f++) { if (vec[f] < menor) { menor=vec[f]; } } Console.WriteLine("El elemento menor es:"+menor); } public void RepiteMenor() { int cant=0; for(int f=0;f < vec.Length;f++) { if (vec[f]==menor) { cant++; } } if (cant > 1) { Console.WriteLine("Se repite el menor en el vector."); }

else { Console.WriteLine("No se repite el menor en el vector."); } Console.ReadLine(); } static void Main(string[] args) { PruebaVector12 pv = new PruebaVector12(); pv.Cargar(); pv.MenorElemento(); pv.RepiteMenor(); } } }

- Vectores (ordenamiento)
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaVector15 { class PruebaVector15 { private int[] vec; public void Cargar() { Console.Write("Cuantos elementos tendr el vector:"); string linea; linea = Console.ReadLine(); int cant; cant=int.Parse(linea); vec=new int[cant]; for(int f=0;f < vec.Length;f++) { Console.Write("Ingrese elemento:"); linea = Console.ReadLine(); vec[f]=int.Parse(linea); } } public void Ordenar() { for (int k = 0; k < vec.Length; k++) { for (int f = 0; f < vec.Length - 1 - k; f++) { if (vec[f] > vec[f + 1]) { int aux; aux = vec[f];

vec[f] = vec[f + 1]; vec[f + 1] = aux; } } } } public void Imprimir() { Console.WriteLine("Vector ordenados de menor a mayor."); for(int f=0;f < vec.Length;f++) { Console.WriteLine(vec[f]); } Console.ReadKey(); } static void Main(string[] args) { PruebaVector15 pv = new PruebaVector15(); pv.Cargar(); pv.Ordenar(); pv.Imprimir(); } } }

- Vectores (ordenamiento con vectores paralelos)


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

namespace PruebaVector17 { class PruebaVector17 { private string[] paises; private int[] habitantes; public void Cargar() { paises=new string[5]; habitantes=new int[5]; Console.WriteLine("Carga de paises y habitantes"); for(int f=0;f < paises.Length;f++) { Console.Write("Ingese el nombre del pais:"); paises[f]=Console.ReadLine(); Console.Write("Ingrese la cantidad de habitantes:"); string linea; linea = Console.ReadLine(); habitantes[f]=int.Parse(linea); }

} public void OrdenarPorNombres() { for (int k = 0; k < paises.Length; k++) { for (int f = 0; f < paises.Length - 1 - k; f++) { if (paises[f].CompareTo(paises[f + 1]) > 0) { string auxpais; auxpais = paises[f]; paises[f] = paises[f + 1]; paises[f + 1] = auxpais; int auxhabitante; auxhabitante = habitantes[f]; habitantes[f] = habitantes[f + 1]; habitantes[f + 1] = auxhabitante; } } } } public void OrdenarPorHabitantes() { for (int k = 0; k < paises.Length; k++) { for (int f = 0; f < paises.Length - 1 - k; f++) { if (habitantes[f] < habitantes[f + 1]) { string auxpais; auxpais = paises[f]; paises[f] = paises[f + 1]; paises[f + 1] = auxpais; int auxhabitante; auxhabitante = habitantes[f]; habitantes[f] = habitantes[f + 1]; habitantes[f + 1] = auxhabitante; } } } } public void Imprimir() { for(int f=0;f < paises.Length;f++) { Console.WriteLine(paises[f] + " - " + habitantes[f]); } } static void Main(string[] args) { PruebaVector17 pv = new PruebaVector17(); pv.Cargar(); pv.OrdenarPorNombres();

Console.WriteLine("Ordenados alfabticamente"); pv.Imprimir(); pv.OrdenarPorHabitantes(); Console.WriteLine("Ordenados por cantidad de habitnates"); pv.Imprimir(); Console.ReadKey(); } } }

- Estructura de datos tipo matriz


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

namespace Matriz4 { class Matriz4 { private int[,] mat; public void Cargar() { mat=new int[2,5]; Console.WriteLine("Carga de la matriz por columna:"); for(int c = 0; c < 5; c++) { for(int f = 0; f < 2; f++) { Console.Write("Ingrese componente " + " de la fila " + f + " y la columna "+ c + " :"); string linea; linea = Console.ReadLine(); mat[f,c]=int.Parse(linea); } } } public void Imprimir() { for(int f = 0; f < 2; f++) { for(int c = 0; c < 5; c++) { Console.Write(mat[f,c]+" "); } Console.WriteLine(); } Console.ReadKey(); } static void Main(string[] args) {

Matriz4 ma = new Matriz4(); ma.Cargar(); ma.Imprimir(); } } }

- Matrices (cantidad de filas y columnas)


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

namespace Matriz7 { class Matriz7 { private int[,] mat; public void Cargar() { Console.Write("Cuantas fila tiene la matriz:"); string linea; linea=Console.ReadLine(); int filas=int.Parse(linea); Console.Write("Cuantas columnas tiene la matriz:"); linea=Console.ReadLine(); int columnas=int.Parse(linea); mat=new int[filas,columnas]; for(int f = 0; f < mat.GetLength(0); f++) { for(int c = 0;c < mat.GetLength(1); c++) { Console.Write("Ingrese componente:"); linea = Console.ReadLine(); mat[f,c]=int.Parse(linea); } } } public void Intercambiar() { for (int c = 0; c < mat.GetLength(0); c++) { int aux = mat[0,c]; mat[0,c] = mat[1,c]; mat[1,c] = aux; } } public void Imprimir() { for(int f = 0; f < mat.GetLength(0); f++) {

for(int c = 0; c < mat.GetLength(1); c++) { Console.Write(mat[f,c]+" "); } Console.WriteLine(); } Console.ReadKey(); } static void Main(string[] args) { Matriz7 ma = new Matriz7(); ma.Cargar(); ma.Intercambiar(); ma.Imprimir(); } } }

using using using using

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

namespace Matriz8 { class Matriz8 { private int[,] mat; public void Cargar() { Console.Write("Cuantas fila tiene la matriz:"); string linea; linea=Console.ReadLine(); int filas=int.Parse(linea); Console.Write("Cuantas columnas tiene la matriz:"); linea=Console.ReadLine(); int columnas=int.Parse(linea); mat=new int[filas,columnas]; for(int f = 0; f < mat.GetLength(0); f++) { for(int c = 0; c < mat.GetLength(1); c++) { Console.Write("Ingrese componente:"); linea = Console.ReadLine(); mat[f,c]=int.Parse(linea); } } } public void ImprimirVertices() { Console.WriteLine("Vrtice superior izquierdo:");

Console.WriteLine(mat[0,0]); Console.WriteLine("Vrtice superior derecho:"); Console.WriteLine(mat[0,mat.GetLength(1)-1]); Console.WriteLine("Vrtice inferior izquierdo:"); Console.WriteLine(mat[mat.GetLength(0)-1,0]); Console.WriteLine("Vrtice inferior derecho:"); Console.WriteLine(mat[mat.GetLength(0)-1,mat.GetLength(1)1]); Console.ReadKey(); } static void Main(string[] args) { Matriz8 ma = new Matriz8(); ma.Cargar(); ma.ImprimirVertices(); } } }

- Matrices y vectores paralelos


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

namespace Matriz10 { class Matriz10 { private string[] paises; private int[,] tempmen; private int[] temptri; public void Cargar() { paises=new String[4]; tempmen=new int[4,3]; for(int f = 0; f < paises.Length; f++) { Console.Write("Ingrese el nombre del pas:"); paises[f]=Console.ReadLine(); for(int c = 0; c < tempmen.GetLength(1); c++) { Console.Write("Ingrese temperatura mensual:"); string linea = Console.ReadLine(); tempmen[f,c]=int.Parse(linea); } } } public void ImprimirTempMensuales() { for(int f = 0; f < paises.Length; f++)

{ Console.Write("Pais:" + paises[f]+":"); for(int c = 0; c < tempmen.GetLength(1); c++) { Console.Write(tempmen[f,c]+" "); } Console.WriteLine(); } } public void CalcularTemperaturaTri() { temptri = new int[4]; for (int f = 0; f < tempmen.GetLength(0); f++) { int suma = 0; for (int c = 0; c < tempmen.GetLength(1); c++) { suma = suma + tempmen[f,c]; } temptri[f] = suma / 3; } } public void ImprimirTempTrimestrales() { Console.WriteLine("Temperaturas trimestrales."); for(int f = 0; f < paises.Length; f++) { Console.WriteLine(paises[f]+" "+temptri[f]); } } public void PaisMayorTemperaturaTri() { int may=temptri[0]; string nom=paises[0]; for(int f = 0; f < paises.Length; f++) { if (temptri[f] > may) { may=temptri[f]; nom=paises[f]; } } Console.WriteLine("Pais con temperatura trimestral mayor es "+ nom + " que tiene una temperatura de "+may); } static void Main(string[] args) { Matriz10 ma = new Matriz10(); ma.Cargar(); ma.ImprimirTempMensuales(); ma.CalcularTemperaturaTri(); ma.ImprimirTempTrimestrales(); ma.PaisMayorTemperaturaTri();

Console.ReadKey(); } } }

- Matrices irregulares o dentadas


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

namespace MatrizIrregular2 { class MatrizIrregular2 { private int[][] mat; public void Cargar() { mat=new int[5][]; for(int f = 0; f < mat.Length; f++) { mat[f]=new int[f+1]; for(int c = 0; c < mat[f].Length; c++) { Console.Write("Ingrese componente:"); string linea = Console.ReadLine(); mat[f][c]=int.Parse(linea); } } } public void Imprimir() { for(int f = 0; f < mat.Length; f++) { for(int c = 0; c < mat[f].Length; c++) { Console.Write(mat[f][c]+" "); } Console.WriteLine(); } Console.ReadKey(); } static void Main(string[] args) { MatrizIrregular2 ma = new MatrizIrregular2(); ma.Cargar(); ma.Imprimir(); } } }

using using using using

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

namespace MatrizIrregular3 { class MatrizIrregular3 { private string[] nombres; private int[][] dias; public void Cargar() { nombres=new string[3]; dias=new int[3][]; for(int f = 0; f < nombres.Length; f++) { Console.Write("Ingrese el nombre del empleado:"); nombres[f]=Console.ReadLine(); Console.Write("Cuantas das falt el empleado:"); string linea = Console.ReadLine(); int faltas=int.Parse(linea); dias[f]=new int[faltas]; for(int c = 0; c < dias[f].Length; c++) { Console.Write("Ingrese nro de da:"); linea = Console.ReadLine(); dias[f][c]=int.Parse(linea); } } } public void Inasistencias() { for(int f = 0; f < nombres.Length; f++) { Console.WriteLine(nombres[f] + " falt " + dias[f].Length + " das"); } } public void EmpleadoMensosFaltas() { int faltas=dias[0].Length; string nom=nombres[0]; for(int f = 1; f < dias.Length; f++) { if (dias[f].Length < faltas) { faltas=dias[f].Length; nom=nombres[f]; } } Console.WriteLine("El empleado que falt menos es "+nom+" con "+faltas+" faltas."); Console.ReadKey();

} static void Main(string[] args) { MatrizIrregular3 ma = new MatrizIrregular3(); ma.Cargar(); ma.Inasistencias(); ma.EmpleadoMensosFaltas(); } } }

- Constructor de la clase
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace PruebaConstructor3 { class EmpleadoFabrica { string nombre; float sueldo; public EmpleadoFabrica() { Console.Write("Ingrese el nombre del empleado:"); nombre = Console.ReadLine(); Console.Write("Ingrese su sueldo:"); string linea = Console.ReadLine(); sueldo = float.Parse(linea); } public void PagaImpuestos() { if (sueldo > 3000) { Console.Write("Debe abonar impuestos"); } else { Console.Write("No paga impuestos"); } Console.ReadKey(); } static void Main(string[] args) { EmpleadoFabrica empleado1; empleado1 = new EmpleadoFabrica(); empleado1.PagaImpuestos(); } }

using using using using

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

namespace PruebaConstructor4 { class OperacionesCalculo { int valor1, valor2; public OperacionesCalculo() { Console.Write("Ingrese primer valor:"); string linea = Console.ReadLine(); valor1=int.Parse(linea); Console.Write("Ingrese segundo valor:"); linea = Console.ReadLine(); valor2=int.Parse(linea); } public void Sumar() { int suma; suma=valor1+valor2; Console.WriteLine("La suma es:"+suma); } public void Restar() { int resta; resta=valor1-valor2; Console.WriteLine("La resta es:"+resta); } public void Multiplicar() { int multiplicacion; multiplicacion=valor1*valor2; Console.WriteLine("La multiplicacin es:"+multiplicacion); } public void Dividir() { int division; division=valor1/valor2; Console.WriteLine("La divisin es:"+division); } static void Main(string[] args) { OperacionesCalculo opera = new OperacionesCalculo();

opera.Sumar(); opera.Restar(); opera.Multiplicar(); opera.Dividir(); Console.ReadKey(); } } }

- Colaboracin de clases
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Colaboracion3 { class Socio { private string nombre; private int antiguedad; public Socio() { Console.Write("Ingrese el nombre del socio:"); nombre = Console.ReadLine(); ; Console.Write("Ingrese la antiguedad:"); string linea = Console.ReadLine(); antiguedad=int.Parse(linea); } public void Imprimir() { Console.WriteLine(nombre+" tiene una antiguedad de "+antiguedad); } public int RetornarAntiguedad() { return antiguedad; } } class Club { private Socio socio1, socio2, socio3; public Club() { socio1=new Socio(); socio2=new Socio(); socio3=new Socio(); }

public void MayorAntiguedad() { Console.Write("Socio con mayor antiguedad:"); if (socio1.RetornarAntiguedad() > socio2.RetornarAntiguedad() && socio1.RetornarAntiguedad() > socio3.RetornarAntiguedad()) { socio1.Imprimir(); } else { if (socio2.RetornarAntiguedad() > socio3.RetornarAntiguedad()) { socio2.Imprimir(); } else { socio3.Imprimir(); } } } static void Main(string[] args) { Club club1 = new Club(); club1.MayorAntiguedad(); Console.ReadKey(); } } }

- Concepto de propiedad
using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace Propiedades3 { class Socio { private string nombre; private int antiguedad; public string Nombre { set { nombre = value; }

get { return nombre; } } public int Antiguedad { set { if (value >= 0) { antiguedad = value; } else { Console.Write("No se puede asignar aun valor negativo a la antiguedad"); } } get { return antiguedad; } } } class Club { private Socio socio1, socio2, socio3; public Club() { socio1 = new Socio(); socio1.Nombre = "Juan"; socio1.Antiguedad = 7; socio2 = new Socio(); socio2.Nombre = "Ana"; socio2.Antiguedad = 3; socio3 = new Socio(); socio3.Nombre = "Martin"; socio3.Antiguedad = 25; } public void MayorAntiguedad() { if (socio1.Antiguedad > socio2.Antiguedad && socio1.Antiguedad > socio3.Antiguedad) { Console.WriteLine("Socio com mayor antiguedad:"+socio1.Nombre); } else { if (socio2.Antiguedad > socio3.Antiguedad) {

Console.WriteLine("Socio com mayor antiguedad:" + socio2.Nombre); } else { Console.WriteLine("Socio com mayor antiguedad:" + socio3.Nombre); } } } static void Main(string[] args) { Club club1 = new Club(); club1.MayorAntiguedad(); Console.ReadKey(); } }

- Ventana de propiedades (Windows Forms)

- Ventana de eventos (Windows Forms)

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplication6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.Text = "Lunes"; } private void button2_Click(object sender, EventArgs e) { label1.Text = "Martes"; } private void button3_Click(object sender, EventArgs e) { label1.Text = "Miercoles"; } private void button4_Click(object sender, EventArgs e) { label1.Text = "Jueves"; } private void button5_Click(object sender, EventArgs e) { label1.Text = "Viernes"; }

private void button6_Click(object sender, EventArgs e) { label1.Text = "Sbado"; } private void button7_Click(object sender, EventArgs e) { label1.Text = "Domingo"; } } }

- Controles comunes - Label

- Controles comunes - Button


using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplicationButton4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button0_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) {

label1.Text = label1.Text + button0.Text; } } private void button1_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button1.Text; } } private void button2_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button2.Text; } } private void button3_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button3.Text; } } private void button4_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button4.Text; } } private void button5_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button5.Text; } } private void button6_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button6.Text; } } private void button7_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button7.Text;

} } private void button8_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button8.Text; } } private void button9_Click(object sender, EventArgs e) { if (label1.Text.Length < 12) { label1.Text = label1.Text + button8.Text; } } } }

- Controles comunes - TextBox


using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplicationTextBox4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(textBox1.Text); } } }

- Controles comunes - CheckBox


using System; using System.Collections.Generic; using System.ComponentModel;

using using using using using

System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplicationCheckBox3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Text = ""; if (checkBox1.Checked == true) { Text = Text + "(" + checkBox1.Text + ")"; } if (checkBox2.Checked == true) { Text = Text + "(" + checkBox2.Text + ")"; } if (checkBox3.Checked == true) { Text = Text + "(" + checkBox3.Text + ")"; } } } }

- Controles comunes - ComboBox


using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplicationComboBox3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Text = textBox1.Text + " - " + comboBox1.Text; } } }

Vous aimerez peut-être aussi