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 Ex_4_ASPNET_04_Array
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Declarando variaveis
- int[] iValoresA = new int[10];
- string sPosição = "";
- //Entrada de dados
- for (int i = 0; i < iValoresA.Length; i++) //.Lenght trás o comprimento do array
- {
- Console.Write("Digite o {0}º valor de A: ", (i + 1));
- iValoresA[i] = Convert.ToInt32(Console.ReadLine());
- }
- Console.WriteLine("\nDigite um valor para X: ");
- int iValorX = Convert.ToInt32(Console.ReadLine());
- //Validação se existem valores de A iguais ao valor de X
- for (int j = 0; j < iValoresA.Length; j++)
- {
- if (iValoresA[j] == iValorX)
- {
- if (sPosição != "")
- {
- sPosição = String.Concat(sPosição, " | ", (j+1), "º");
- }
- else
- {
- sPosição = String.Concat("\nDentre os 10 numeros digitados para 'A', nas seguintes posições" +
- " existem os mesmos valores que o informado para 'X': \n", (j+1), "º");
- }
- }
- }
- //Saída dos dados
- if(sPosição == "")
- {
- Console.WriteLine("\nNenhum dos números digitados para 'A' foi o mesmo que o digitado para 'X'!");
- }
- else
- {
- Console.WriteLine("{0}", sPosição);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement