• WORD
  • FORMATO AUTOMATICO Y ESTILOS
  • INSERTAR CUADRO DE TEXTO Y ECUACION
  • REFERENCIASTABLA DE CONTENIDO Y BIBLIOGRAFIA
  • Ir a Prácticas
  • EXCEL
  • FORMULAS I y II
  • TABLAS Y GRAFICOS DINAMICOS
  • SUBTOTALES Y BASE DE DATOS
  • MACROS
  • Ir a Prácticas
  • AUTOCAD
  • 2D:DIBUJO Y ACOTAR
  • INSERTAR BLOQUES Y PLOT
  • 3D: MODELADO Y EDICION DE SOLIDOS
  • RENDER Y ANIMACIONES
  • Ir a Prácticas

viernes, 20 de febrero de 2026

C# LISTAS

LISTAS:

Una lista en C# es una colección dinámica de elementos del mismo tipo que crece automáticamente, a diferencia de los arrays que tienen tamaño fijo.

aracterísticas Principales

  • Tipo genérico: List<string>, List<int>, List<Alumno>
  • Espacio de nombres: using System.Collections.Generic;
  • Acceso por índice: lista[0], lista[1]
  • Propiedades: lista.Count (número de elementos)

CODIGO:

using System;

using System.Collections.Generic;

 

namespace Ejemplo

{

    internal class Program

    {

        static void Main(string[] args)

        {

            List<string> alumnos = new List<string>();  // Sin espacios extra

            alumnos.Add("pepe");

            alumnos.Add("joaquin");

            alumnos.Add("pepe");

            alumnos.Add("kimberly");

            alumnos.Add("eusebio");

            alumnos.Remove("eusebio");

            alumnos.Insert(1, "paola");

            Console.WriteLine(alumnos[0]);

            Console.WriteLine(alumnos.Count);

            Console.WriteLine(alumnos.IndexOf("joaquin"));

            Console.WriteLine(alumnos.LastIndexOf("pepe"));

            Console.WriteLine(alumnos.Contains("joaquin"));

            alumnos.Sort();

            alumnos.Reverse();

            //alumnos.Clear();

            string[] coleagiales=alumnos.ToArray();

 

 

 

            foreach (string alumn in alumnos)

            {

                Console.WriteLine(alumn);

            }

            Console.ReadKey();

            //ingreso de nombres:

            List<string> LIST2 = new List<string>();  // Tu lista LIST 2

            string dato;

 

            Console.WriteLine("=== LIST 2 ===");

            Console.Write("¿Cuántos datos ingresaras? ");

            int cantidad = int.Parse(Console.ReadLine());

 

            // Ingresar datos a LIST 2

            for (int i = 0; i < cantidad; i++)

            {

                Console.Write($"Dato {i + 1}: ");

                dato = Console.ReadLine();

                LIST2.Add(dato);  // Agregar a LIST 2

            }

 

            // Mostrar LIST 2

            Console.WriteLine("\nContenido de LIST 2:");

            for (int i = 0; i < LIST2.Count; i++)

            {

                Console.WriteLine($"[{i}] {LIST2[i]}");

            }

            Console.ReadKey();

        }

    }

}

   

Listas enlazadas

CODIGO:

using System;

 

// Clase Nodo que representa cada elemento de la lista

public class Nodo

{

    public int dato;        // Dato almacenado en el nodo

    public Nodo siguiente;  // Referencia al siguiente nodo

 

    public Nodo(int dato)

    {

        this.dato = dato;

        this.siguiente = null;

    }

}

 

// Clase ListaEnlazadaSimple que maneja todas las operaciones

public class ListaEnlazadaSimple

{

    private Nodo inicio;    // Puntero al primer nodo

 

    public ListaEnlazadaSimple()

    {

        inicio = null;

    }

 

    // 1. Insertar al inicio

    public void InsertarInicio(int dato)

    {

        Nodo nuevo = new Nodo(dato);

        nuevo.siguiente = inicio;

        inicio = nuevo;

    }

 

    // 2. Insertar al final

    public void InsertarFinal(int dato)

    {

        Nodo nuevo = new Nodo(dato);

 

        if (inicio == null)

        {

            inicio = nuevo;

            return;

        }

 

        Nodo actual = inicio;

        while (actual.siguiente != null)

        {

            actual = actual.siguiente;

        }

        actual.siguiente = nuevo;

    }

 

    // 3. Buscar un elemento

    public bool Buscar(int dato)

    {

        Nodo actual = inicio;

        while (actual != null)

        {

            if (actual.dato == dato)

                return true;

            actual = actual.siguiente;

        }

        return false;

    }

 

    // 4. Eliminar un elemento específico

    public bool Eliminar(int dato)

    {

        if (inicio == null)

            return false;

 

        // Si es el primer nodo

        if (inicio.dato == dato)

        {

            inicio = inicio.siguiente;

            return true;

        }

 

        // Buscar el nodo anterior al que se quiere eliminar

        Nodo actual = inicio;

        while (actual.siguiente != null)

        {

            if (actual.siguiente.dato == dato)

            {

                actual.siguiente = actual.siguiente.siguiente;

                return true;

            }

            actual = actual.siguiente;

        }

        return false;

    }

 

    // 5. Mostrar todos los elementos

    public void Mostrar()

    {

        if (inicio == null)

        {

            Console.WriteLine("La lista está vacía");

            return;

        }

 

        Nodo actual = inicio;

        Console.Write("Lista: ");

        while (actual != null)

        {

            Console.Write(actual.dato + " -> ");

            actual = actual.siguiente;

        }

        Console.WriteLine("NULL");

    }

 

    // 6. Obtener tamaño de la lista

    public int Tamano()

    {

        int count = 0;

        Nodo actual = inicio;

        while (actual != null)

        {

            count++;

            actual = actual.siguiente;

        }

        return count;

    }

 

    // 7. Verificar si está vacía

    public bool EstaVacia()

    {

        return inicio == null;

    }

}

 

// Programa principal para probar la lista

class Program

{

    static void Main(string[] args)

    {

        ListaEnlazadaSimple lista = new ListaEnlazadaSimple();

 

        Console.WriteLine("=== DEMOSTRACIÓN DE LISTA ENLAZADA SIMPLE ===\n");

 

        // Insertar al inicio

        lista.InsertarInicio(10);

        lista.InsertarInicio(20);

        lista.InsertarInicio(30);

        Console.WriteLine("1. Insertar al inicio (30,20,10):");

        lista.Mostrar();

 

        // Insertar al final

        lista.InsertarFinal(40);

        lista.InsertarFinal(50);

        Console.WriteLine("\n2. Insertar al final (agrega 40,50):");

        lista.Mostrar();

 

        // Buscar

        Console.WriteLine($"\n3. Buscar 40: {lista.Buscar(40)}");

        Console.WriteLine($"Buscar 100: {lista.Buscar(100)}");

 

        // Tamaño

        Console.WriteLine($"\n4. Tamaño de la lista: {lista.Tamano()}");

 

        // Eliminar

        Console.WriteLine("\n5. Eliminar 20:");

        lista.Eliminar(20);

        lista.Mostrar();

 

        Console.WriteLine($"\n6. ¿Está vacía? {lista.EstaVacia()}");

 

        Console.WriteLine("\nPresiona cualquier tecla para salir...");

        Console.ReadKey();

    }

}

 

PROGRAMA QUE INGRESA NODOS Y REPORTA LISTAS ENLAZADAS

using System;

 

public class Nodo

{

    public int dato;

    public Nodo siguiente;

 

    public Nodo(int dato)

    {

        this.dato = dato;

        this.siguiente = null;

    }

}

 

public class ListaSimple

{

    private Nodo inicio;

 

    public ListaSimple()

    {

        inicio = null;

    }

 

    // Insertar al final

    public void Agregar(int dato)

    {

        Nodo nuevo = new Nodo(dato);

        if (inicio == null)

        {

            inicio = nuevo;

            return;

        }

 

        Nodo actual = inicio;

        while (actual.siguiente != null)

        {

            actual = actual.siguiente;

        }

        actual.siguiente = nuevo;

    }

 

    // Imprimir todos los nodos

    public void Imprimir()

    {

        if (inicio == null)

        {

            Console.WriteLine("La lista está vacía");

            return;

        }

 

        Console.Write("Nodos: ");

        Nodo actual = inicio;

        while (actual != null)

        {

            Console.Write(actual.dato);

            if (actual.siguiente != null)

                Console.Write(" -> ");

            actual = actual.siguiente;

        }

        Console.WriteLine();

    }

}

 

class Program

{

    static void Main(string[] args)

    {

        ListaSimple lista = new ListaSimple();

        Console.WriteLine("=== LISTA ENLAZADA SIMPLE INTERACTIVA ===\n");

 

        // Ingresar datos

        Console.WriteLine("Ingresa números (0 para terminar):");

        int numero;

        do

        {

            Console.Write("Número: ");

            numero = int.Parse(Console.ReadLine());

            if (numero != 0)

            {

                lista.Agregar(numero);

            }

        } while (numero != 0);

 

        Console.WriteLine("\n--- RESULTADO ---");

        lista.Imprimir();

 

        Console.WriteLine("\nPresiona cualquier tecla para salir...");

        Console.ReadKey();

    }

}

 

COLAS

>using System;

 

// Clase Nodo para la estructura de la cola

public class Nodo

{

    public int dato;

    public Nodo siguiente;

   

    public Nodo(int valor)

    {

        dato = valor;

        siguiente = null;

    }

}

 

// Clase Cola que usa nodos enlazados

public class Cola

{

    private Nodo inicio;

    private Nodo fin;

   

    public Cola()

    {

        inicio = null;

        fin = null;

    }

   

    // Encolar (agregar al final)

    public void Encolar(int valor)

    {

        Nodo nuevo = new Nodo(valor);

       

        if (EstaVacia())

        {

            inicio = nuevo;

            fin = nuevo;

        }

        else

        {

            fin.siguiente = nuevo;

            fin = nuevo;

        }

    }

   

    // Desencolar (eliminar del inicio)

    public int Desencolar()

    {

        if (EstaVacia())

        {

            throw new InvalidOperationException("La cola está vacía");

        }

       

        int valor = inicio.dato;

        Nodo temp = inicio;

       

        if (inicio == fin)

        {

            inicio = null;

            fin = null;

        }

        else

        {

            inicio = inicio.siguiente;

        }

       

        temp.siguiente = null;

        return valor;

    }

   

    // Verificar si la cola está vacía

    public bool EstaVacia()

    {

        return inicio == null;

    }

   

    // Mostrar todos los elementos de la cola

    public void Mostrar()

    {

        if (EstaVacia())

        {

            Console.WriteLine("La cola está vacía");

            return;

        }

       

        Nodo actual = inicio;

        Console.Write("Cola: ");

        while (actual != null)

        {

            Console.Write(actual.dato + " ");

            actual = actual.siguiente;

        }

        Console.WriteLine();

    }

}

 

// Programa principal para probar la cola

class Program

{

    static void Main(string[] args)

    {

        Cola miCola = new Cola();

       

        Console.WriteLine("=== DEMO COLA CON NODOS EN C# ===\n");

       

        // Encolar elementos

        miCola.Encolar(10);

        miCola.Encolar(20);

        miCola.Encolar(30);

        miCola.Mostrar();  // Salida: Cola: 10 20 30

       

        // Desencolar

        Console.WriteLine($"Desencolado: {miCola.Desencolar()}");  // 10

        miCola.Mostrar();  // Salida: Cola: 20 30

       

        // Más operaciones

        miCola.Encolar(40);

        miCola.Encolar(50);

        miCola.Mostrar();  // Salida: Cola: 20 30 40 50

       

        Console.WriteLine($"¿Está vacía? {miCola.EstaVacia()}");

    }

} 

miércoles, 18 de febrero de 2026

JAVA: TIEMPO

 TIEMPO

Java maneja el tiempo principalmente con la API java.time (introducida en Java 8), que ofrece clases inmutables y thread-safe para fechas, horas y duraciones, reemplazando las obsoletas Date y Calendar. Estas clases evitan problemas comunes como mutabilidad y zonas horarias ambiguas.

Clases Principales                                               

LocalDate: Representa una fecha sin hora (ej: 2026-02-18).

LocalTime: Representa una hora sin fecha (ej: 07:04:00).

LocalDateTime: Combina fecha y hora sin zona horaria.

Instant: Punto en el tiempo en UTC (nanosegundos desde epoch).

ZonedDateTime: Fecha/hora con zona horaria específica.

Duraciones y Períodos

Duration mide tiempo en unidades como segundos/nanos (para horas/minutos). Period mide en años/meses/días (calendáricos)

CODIGO:

 import java.time.*;

public class EjemploTiempo {

    public static void main(String[] args) {

        // LocalDateTime actual

        LocalDateTime ahora = LocalDateTime.now();

        System.out.println("Ahora: " + ahora);

       

        // Duración entre dos tiempos

        LocalTime inicio = LocalTime.of(9, 0);

        LocalTime fin = LocalTime.of(10, 30);

        Duration duracion = Duration.between(inicio, fin);

        System.out.println("Duración: " + duracion.toMinutes() + " minutos");

       

        // Periodo entre fechas

        LocalDate hoy = LocalDate.now();

        LocalDate futuro = hoy.plusMonths(3);

        Period periodo = Period.between(hoy, futuro);

        System.out.println("Periodo: " + periodo.getMonths() + " meses");

       

        // Instant (UTC)

        Instant epoch = Instant.now();

        System.out.println("Instant: " + epoch);

    }

}

Operaciones Comunes

Agrega/resta tiempo con plusX()/minusX(), formatea con DateTimeFormatter y parsea con parse(). Ejemplo de formateo:

CODIGO:

 DateTimeFormatter fmt = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");

String texto = ahora.format(fmt);  // "18/02/2026 07:04"

LocalDateTime parseada = LocalDateTime.parse(texto, fmt);

miércoles, 11 de febrero de 2026

java: arrays 2

ARRAYS 2

La clase java.util.Arrays en Java es una herramienta fundamental que proporciona métodos estáticos para manipular matrices (arrays), como ordenar, buscar, rellenar y convertir a cadenas. Es de utilidad directa y no requiere instanciación; se importa con import java.util.Arrays; para facilitar tareas comunes de gestión de datos. 

  • sort(): Ordena el array de forma ascendente.
  • binarySearch(): Busca un elemento en un array ordenado.
  • equals(): Compara si dos arrays son iguales.
  • fill(): Asigna un valor específico a todos los elementos.
  • toString(): Convierte el array en una cadena legible.
  • copyOf() / copyOfRange(): Copia un array o una parte de él. 

CODIGO:

package javaapplication5;

import java.util.Arrays;

import java.util.Scanner;

 

public class JavaApplication5 {

 

    public static void main(String[] args) {

        Scanner teclado=new Scanner(System.in); 

        int[] numeros = {5, 2, 8, 1, 9};

       

        // Ordenar el array

        Arrays.sort(numeros);

        System.out.println(Arrays.toString(numeros)); // [1, 2, 5, 8, 9]

       

        // Buscar un elemento (debe estar ordenado)

        int pos = Arrays.binarySearch(numeros, 5);

        System.out.println("Posicion de 5: " + pos); // 2

       

        // Verificar si dos arrays son iguales

        int[] copia = {1, 2, 5, 8, 9};

        boolean iguales = Arrays.equals(numeros, copia);

        System.out.println("Iguales? " + iguales); // true

       

        String[] frutas = {"Manzana", "Pera", "Uva"};

        for(int i = 0; i < frutas.length; i++) {

        System.out.println(frutas[i]);

        }

       

       //ordenar  en letras

       String[] palabras = {"Zebra", "apple", "Banana", "casa", "perro"};

       

        Arrays.sort(palabras, String.CASE_INSENSITIVE_ORDER);

        System.out.println("Orden alfabético (sin distinguir mayúsculas):");

        for (String palabra : palabras) {

            System.out.println(palabra);

        }

        //ejemplo notas de alumnos

        String[] alumnos={"jose","pedro","denis","karla"};

        int[] notas={14,20,15,17};

        System.out.println("ingresa el alumno:");

        String estudiante=teclado.nextLine();

        for(int i=0;i<4;i++){

            if(alumnos[i].equals(estudiante)){

                System.out.println("estudiante "+estudiante+" su nota es "+notas[i]);

            }

        }

        }

}

 

viernes, 6 de febrero de 2026

C#: MATRICES

 ARREGLOS(MATRICES)


INTRODUCIR UNA MATRIZ:

using System;

 

class Program

{

    static void Main()

    {

                Console.Write("¿Cuántas FILAS? ");

        int filas = int.Parse(Console.ReadLine());

 

        Console.Write("¿Cuántas COLUMNAS? ");

        int columnas = int.Parse(Console.ReadLine());

 

       

        int[,] matriz = new int[filas, columnas];

 

        Console.WriteLine("\n--- INGRESAR DATOS ---");

        for (int i = 0; i < matriz.GetLength(0); i++)  // GetLength(0) = FILAS

        {

            for (int j = 0; j < matriz.GetLength(1); j++)  // GetLength(1) = COLUMNAS

            {

                Console.Write($"matriz[{i},{j}] = ");

                matriz[i, j] = int.Parse(Console.ReadLine());

            }

        }

 

        // 4. MOSTRAR matriz

        Console.WriteLine("\n--- MATRIZ LLENA ---");

        for (int i = 0; i < matriz.GetLength(0); i++)

        {

            for (int j = 0; j < matriz.GetLength(1); j++)

            {

                Console.Write($"{matriz[i, j],4}");

            }

            Console.WriteLine();

        }

    }

}

 

 

BUSQUEDA DE MATRICES DESORDENADAS CON BUSQUEDA ,LINEAL

using System;

 

class Program

{

    public static int[] BuscarLineal(int[,] matriz, int valor)

    {

        int filas = matriz.GetLength(0);

        int columnas = matriz.GetLength(1);

 

        // Recorrer TODA la matriz elemento por elemento

        for (int i = 0; i < filas; i++)

        {

            for (int j = 0; j < columnas; j++)

            {

                if (matriz[i, j] == valor)

                {

                    return new int[] { i, j };  // ¡Encontrado!

                }

            }

        }

        return new int[] { -1, -1 };  // No encontrado

    }

 

    static void ImprimirMatriz(int[,] matriz)

    {

        int filas = matriz.GetLength(0);

        for (int i = 0; i < filas; i++)

        {

            for (int j = 0; j < matriz.GetLength(1); j++)

                Console.Write($"{matriz[i, j],4}");

            Console.WriteLine();

        }

    }

 

 

 

    static void Main()

    {

        // Matriz DESORDENADA

        int[,] matrizDesordenada = {

            { 5, 1, 9 },

            { 3, 8, 2 },

            { 7, 4, 6 }

        };

 

        Console.WriteLine("Matriz DESORDENADA:");

        ImprimirMatriz(matrizDesordenada);

        Console.WriteLine();

 

        // Probar búsquedas

        int[] resultado1 = BuscarLineal(matrizDesordenada, 8);

        Console.WriteLine($"Buscar 8 → [{resultado1[0]}, {resultado1[1]}]");  // [1,1]

 

        int[] resultado2 = BuscarLineal(matrizDesordenada, 10);

        Console.WriteLine($"Buscar 10 → [{resultado2[0]}, {resultado2[1]}]"); // [-1,-1]

    }

}

Ordenar una matriz conviertiendola en un array

using System;

 

class Program

{

    static void Main()

    {

        // Matriz DESORDENADA inicial

        int[,] matriz = {

            { 5, 1, 7 },

            { 3, 8, 2 },

            { 7, 4, 6 }

        };

 

        Console.WriteLine("MATRIZ ORIGINAL:");

        ImprimirMatriz(matriz);

 

        // ORDENAR TODA LA MATRIZ

        OrdenarMatriz(matriz);

 

        Console.WriteLine("\nMATRIZ ORDENADA:");

        ImprimirMatriz(matriz);

    }

 

   

    static void OrdenarMatriz(int[,] matriz)

    {

        int filas = matriz.GetLength(0);

        int cols = matriz.GetLength(1);

 

       

        int[] temp = new int[filas * cols];

        int index = 0;

        for (int i = 0; i < filas; i++)

            for (int j = 0; j < cols; j++)

                temp[index++] = matriz[i, j];

 

        Array.Sort(temp);

 

       

        index = 0;

        for (int i = 0; i < filas; i++)

            for (int j = 0; j < cols; j++)

                matriz[i, j] = temp[index++];

    }

 

    static void ImprimirMatriz(int[,] matriz)

    {

        for (int i = 0; i < matriz.GetLength(0); i++)

        {

            for (int j = 0; j < matriz.GetLength(1); j++)

                Console.Write($"{matriz[i, j],4}");

            Console.WriteLine();

        }

    }

}

 

Busqueda de elementos en matrices

Método GetLength(0)->filas

Método GetLength(1)->columnas

 

 

using System;

 

class Program

{

    // Método estático debe estar dentro de la clase

    public static int[] BuscarEsquinas(int[,] matriz, int valor)

    {

        int fila = 0;

        int col = matriz.GetLength(1) - 1;

 

        while (fila < matriz.GetLength(0) && col >= 0)

        {

            if (matriz[fila, col] == valor)

            {

                return new int[] { fila, col };

            }

            else if (valor < matriz[fila, col])

            {

                col--;  // Descartar columna

            }

            else

            {

                fila++;  // Descartar fila

            }

        }

        return new int[] { -1, -1 };

    }

 

    static void Main()

    {

        // Uso para matriz ordenada:

        int[,] matrizOrdenada = {

            { 1, 4, 7 },

            { 2, 5, 8 },

            { 3, 6, 9 }

        };

 

        int[] resultado = BuscarEsquinas(matrizOrdenada, 5);

        Console.WriteLine($"Encontrado en [{resultado[0]}, {resultado[1]}]");  // [1, 1]

    }

}