Facebook
From Sharp Owl, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 98
  1.    //definición del vector
  2.  
  3.             int[] arrayNumeros;//definición del array
  4.             arrayNumeros = new int[5];//Inicialización array
  5.  
  6.             //Asignación de valores al Array
  7.             arrayNumeros[0] = 20;
  8.             arrayNumeros[1] = 40;
  9.             arrayNumeros[2] = 60;
  10.             arrayNumeros[3] = 80;
  11.             arrayNumeros[4] = 10;
  12.  
  13.             //Mostrar elementos de larray
  14.             Console.WriteLine("Valor pos 0: " + arrayNumeros[0]);
  15.             Console.WriteLine("Valor pos 2: " + arrayNumeros[2]);
  16.             Console.WriteLine("Valor pos 4: " + arrayNumeros[4]);
  17.  
  18.             arrayNumeros[2] = 300;
  19.             Console.WriteLine("Valor pos 2: " + arrayNumeros[2]);
  20.             Console.WriteLine("---------------------------------");
  21.  
  22.          
  23.  
  24.             //Definición/Inicialización array valores fijos
  25.             double[] arraypesos = { 50.4, 70, 80.5 };
  26.  
  27.             //mostrar elementos del array
  28.             Console.WriteLine("Valor pos 0: " + arraypesos[0]);
  29.             Console.WriteLine("Valor pos 1: " + arraypesos[1]);
  30.             Console.WriteLine("Valor pos 2: " + arraypesos[2]);
  31.  
  32.             //--------------------------------------------------//
  33.             double[] arraypromedionotas;
  34.             Console.WriteLine("ingrese la cantidad de estudiantes");
  35.             _ = int.TryParse(Console.ReadLine(), out int cantNotas);
  36.  
  37.             //definir array segun tamaño ingresado por usuario
  38.             arraypromedionotas=new double[cantNotas];
  39.  
  40.             Console.ReadKey();