Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void recursividadeVetor(int[] vetor, int posicao) {
- if ( posicao == vetor.Length ) {
- return;
- }
- vetor[posicao] = posicao+1;
- //apenas mostrar o vetor
- Console.WriteLine("Preencheu a posição {0}",posicao);
- Console.WriteLine("Vetor preenchido: ");
- for ( int i = 0; i < vetor.Length; ++i ) {
- Console.WriteLine( vetor[ i ] + " ");
- }
- //fim mostrar
- recursividadeVetor( vetor , posicao + 1 );
- }
- public static void Main(string[] args)
- {
- int[] vetor = new int[10 ];
- recursividadeVetor( vetor , 0 );
- Console.WriteLine("Vetor preenchido final: ");
- for ( int i = 0; i < vetor.Length; ++i ) {
- Console.WriteLine( vetor[ i ] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment