Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Arrays01
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Definición vector
- int[] arrayNumeros; // Definición del Array
- arrayNumeros = new int[5]; // Inicialización array
- // Asignación de valores al Array
- arrayNumeros[0] = 20;
- arrayNumeros[1] = 40;
- arrayNumeros[2] = 60;
- arrayNumeros[3] = 80;
- arrayNumeros[4] = 10;
- // Mostrar elementos del Array
- Console.WriteLine("Valor pos 0: "+arrayNumeros[0]);
- Console.WriteLine("Valor pos 2: " + arrayNumeros[2]);
- Console.WriteLine("Valor pos 4: " + arrayNumeros[4]);
- arrayNumeros[2] = 300;
- Console.WriteLine("Nuevo valor pos 2: " + arrayNumeros[2]);
- Console.WriteLine("--------------------------");
- //Definición/Inicialización array valores fijos
- double[] arrayPesos = { 50.4, 70, 80.5 };
- // Mostrar elementos del Array
- Console.WriteLine("Valor pos 0: " + arrayPesos[0]);
- Console.WriteLine("Valor pos 1: " + arrayPesos[1]);
- Console.WriteLine("Valor pos 2: " + arrayPesos[2]);
- /*************************************************/
- Console.WriteLine("--------------------------");
- // Visualización todos los valores del array
- for (byte i=0; i < arrayPesos.Length; i++)
- {
- Console.WriteLine("Array pos: {0} es: {1}",i,arrayPesos[i]);
- }
- /*************************************************/
- double[] arrayPromedioNotas;
- Console.WriteLine("Ingrese la cantidad de estudiantes");
- _ = int.TryParse(Console.ReadLine(), out int cantNotas);
- // Definir array según tamaño ingresado por usuario
- arrayPromedioNotas = new double[cantNotas];
- // LLenar los elementos del array
- for (byte i=0; i < arrayPromedioNotas.Length; i++)
- {
- Console.WriteLine("Cual es el promedio del estudiante {0}",(i+1));
- arrayPromedioNotas[i] = double.Parse(Console.ReadLine());
- //_ = double.TryParse(Console.ReadLine(), out arrayPromedioNotas[i]);
- }
- // VIsualizar elementos del array
- for (byte i=0; i < arrayPromedioNotas.Length; i++)
- {
- Console.WriteLine("EL promedio del estudiante {0} es: {1}",(i+1), arrayPromedioNotas[i]);
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement