Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static System.Boolean IsNumeric(System.Object Expression)
- {
- if (Expression == null || Expression is DateTime)
- return false;
- if (Expression is Int16 || Expression is Int32 || Expression is Int64 || Expression is Decimal || Expression is Single || Expression is Double || Expression is Boolean)
- return true;
- try
- {
- if (Expression is string)
- Double.Parse(Expression as string);
- else
- Double.Parse(Expression.ToString());
- return true;
- }
- catch { } // just dismiss errors but return false
- return false;
- }
- static void Main(string[] args)
- {
- int[] vetor = new int[16];
- for(int i = 0; i < vetor.Count(); i++)
- {
- debugKey:
- Console.Write("Digite o " + (i + 1) + "º número: ");
- string n = Console.ReadLine();
- if (IsNumeric(n))
- {
- vetor[i]= int.Parse(n);
- Console.WriteLine("");
- }
- else
- {
- Console.WriteLine("");
- Console.WriteLine("Error: Valor invalido!");
- Console.WriteLine("");
- goto debugKey;
- }
- }
- // Copiar valores a outro array
- int[] vetor2 = new int[vetor.Count()];
- for (int i = 0; i < vetor2.Count(); i++)
- {
- vetor2[i] = vetor[i];
- }
- // Inverter Valores
- for (int i = 0; i < 8; i++)
- {
- vetor[i] = vetor2[15 - i];
- vetor[15 - i] = vetor2[i];
- }
- Console.WriteLine("");
- Console.WriteLine("Valores dos Vetores");
- for (int i = 0; i < vetor.Count(); i++)
- {
- Console.WriteLine("Vetor nº" + (i + 1) +": " + vetor[i]);
- }
- Console.Read();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement