Disclaimer: Make sure you tried enough before checking the solution
Problem: https://codeforces.com/group/MWSDmqGsZm/contest/223339/problem/C
#include <iostream> #include <algorithm> #include <iomanip> #include <string> #include <cmath> #include <cstring> using namespace std; bool first = false; void printToNum(int num) { if (num == 0) { return; } if (first) { cout << " "; } first = true; cout << num; //! we can't use postfix here return printToNum(--num); } int main() { int num; cin >> num; printToNum(num); }
Assiut University Training – Newcomers Solution Recursion