hercioneto

Algoritmo 2 de 25-09-18

Sep 25th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11.     public class Program
  12.     {
  13.        
  14.          public static void recursividade(int numero, int passo, int exec) {
  15.             Console.WriteLine("Estou contando {0}", numero);
  16.  
  17.            if (exec <=30)
  18.             {
  19.                
  20.                
  21.                 Console.WriteLine("Contando {0}", numero);
  22.                 recursividade(numero + passo, passo, exec+1);
  23.             }
  24.              Console.WriteLine("Voltei aqui...{0}", numero);
  25.         }
  26.        
  27.         public static void Main(string[] args)
  28.         {
  29.             int passo = 0;
  30.             int numero = 0;
  31.             Console.Write("Leia o passo: ");
  32.             passo = Convert.ToInt32(Console.ReadLine());
  33.             Console.Write("Leia o número: ");
  34.             numero = Convert.ToInt32(Console.ReadLine());
  35.                        
  36.             Console.WriteLine("Início!");
  37.             recursividade(numero, passo, 0);;
  38.             Console.WriteLine("Fim!");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment