You are on page 1of 4

FUNCIONES

1) Hacer una funcin que te muestre la ltima cadena de una palabra.

using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace FUNCIONES1
{
class Program
{
public static void letra()
{
string word;
Console.WriteLine("Escriba una palabra: ");
word = Console.ReadLine();
Console.WriteLine("{0}", word[word.Length-1]);
Console.ReadLine();
}
static void Main(string[] args)
{
letra();
}
}
}

2) Realizar un programa que te diga el nmero mayor de tres nmeros .

using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace FUNCIONES2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Ingrese un numero");
int A = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Ingrese un numero");
int B = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Ingrese un numero");
int C = Convert.ToInt16(Console.ReadLine());
if(A > B && A > C){
Console.WriteLine("El numero mayor es "+A);
}else{
if(B > A && B > C){
Console.WriteLine("El numero mayor es "+B);
}else{

Console.WriteLine("El numero mayor es "+C);


}
}
Console.ReadLine();
}
}
}
4) Programa que haga las operaciones de sumar ,multiplicar,factorialy el
menor nmero.
5) using System;
6) using System.Collections.Generic;
7) using System.Linq;
8) using System.Text;
9) using System.Threading.Tasks;
10)
11) namespace FUNCIONES4
12) {
13)
class Program
14)
{
15)
enum Operacion { Suma, Multiplicacion, Factorial, Menor };
16)
17)
static void Main()
18)
{
19)
Console.Write("Primer numero: ");
20)
int n1 = int.Parse(Console.ReadLine());
21)
Console.Write("Segundo numero: ");
22)
int n2 = int.Parse(Console.ReadLine());
23)
Console.WriteLine("Suma: {0}", Funcion(n1, n2,
Operacion.Suma));
24)
Console.WriteLine("Multiplicacin: {0}", Funcion(n1, n2,
Operacion.Multiplicacion));
25)
Console.WriteLine("{0}!: {1}", n1, Funcion(n1, 0,
Operacion.Factorial));
26)
Console.WriteLine("{0}!: {1}", n2, Funcion(n2, 0,
Operacion.Factorial));
27)
Console.WriteLine("Menor: {0}", Funcion(n1, n2,
Operacion.Menor));
28)
Console.ReadKey();
29)
}
30)
static int Funcion(int a, int b, Operacion op)
31)
{
32)
switch (op)
33)
{
34)
case Operacion.Suma: return a + b;
35)
case Operacion.Multiplicacion: return a * b;
36)
case Operacion.Factorial:
37)
return a <= 1 ? a : a * Funcion(a - 1, 0,
Operacion.Factorial);
38)
case Operacion.Menor: return a < b ? a : b;
39)
default: return 0;
40)
}
41)
}
42)
}
43) }

VECTORES
1) Programa que te ordene de menor a mayor con vectores.
using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VECTOR1
{
class Program
{
static void Main(string[] args)
{
int[] vector = new int[10];
for (int i = 0; i < 10; i++)
{
Console.Write("Elemento {0}: ", i + 1);
vector[i] = Int32.Parse(Console.ReadLine());
}
for (int i = 0; i < 10; i++)
Console.Write("{0} ", vector[i]);
Console.ReadLine();
}
}

}
2) Hacer una aplicacin que entre una serie de valores numricos desde el teclado, los
almacene en un vector y sume los elementos de las posiciones pares, lo mismo que las
posiciones impares por separados.

MATRICES
1) Hacer un programa que te dibuje una matriz.
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace MATRIZ1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Tamanio de matriz: ");
int tam = int.Parse(Console.ReadLine());
int[,] matriz = new int[tam, tam]; //matriz 3 x 3
int cont = 1;
//Llenado de matriz
for (int i = 0; i < tam; i++)
for (int j = 0; j < tam; j++)
matriz[i, j] = cont++;
//Impresion
for (int i = 0; i < tam; i++)
{
for (int j = 0; j < tam; j++)
Console.Write(string.Format("{0,4:D}", matriz[i, j]));

Console.WriteLine();
}
Console.ReadKey();
}
}
}

You might also like