Created
June 29, 2019 04:39
-
-
Save ampulhetadosaber/33a359dab10f405dbb405f60e595371e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
void solve(int numero){ // Modo Recursivo | |
cout << numero << "\n"; | |
if(numero==1)return; // Chamado de caso base, interrompe a recursão de se chamar infinitamente, causando "Tempo Limite Excedido" | |
solve(numero-1); // Função chamando a si mesma, gerando uma recursão. | |
} | |
int main(){ | |
int n; | |
cin >> n; | |
solve(n); | |
for(int i=n; i>=1; i--){ // Modo Iterativo | |
cout << i << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment