Advertisement
JottaJames

EX_7 C#_ASPNET_04_ARRAY

Apr 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Ex_7_ASPNET_04_Array
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Declaracao de variaveis
  14.             int[] iValores = new int[10];
  15.             Random random = new Random();
  16.  
  17.             // Preenche array com numeros aleatórios
  18.             for (int i = 0; i < iValores.Length; i++)
  19.             {
  20.                 iValores[i] = random.Next(1, 26);
  21.                 Console.WriteLine("{0}", iValores[i]);
  22.             }
  23.  
  24.             //Ignora o 1º elemento do iValores e dá saída dos dados
  25.             int j = 0;
  26.             Console.WriteLine("\nValores anteriores, sem o valor da 1º posição: ");
  27.             for (int i = 0; i < iValores.Length; i++)
  28.             {
  29.                 if (i != 0)
  30.                 {
  31.                     iValores[j] = iValores[i];
  32.                     j++;
  33.  
  34.                     Console.WriteLine("{0}", iValores[j]);
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement