Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishak798 authored Feb 12, 2024
1 parent abcb095 commit c453ffd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Structures/Functions/count.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;
int inp = 1;

vector<int> printcount(int n)
{
vector<int> vec;
if (inp <= n)
{
vec.push_back(inp);
inp++;
printcount(n);
}
return vec;
}
int main()
{
int n;
cin >> n;

printcount(n);
for (auto it : vec)
{
cout << it << " ";
}
return 0;
}
Binary file added Structures/Functions/count.exe
Binary file not shown.
27 changes: 27 additions & 0 deletions Structures/Recursion/printcountwithoutloop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;
vector<int> printnumber(int x)
{

vector<int> vec;
vec.push_back(x);

if (x != 0)
{
x--;
printnumber(x);
vec.push_back(x);
}
return vec;
}
int main()
{
int x;
cin >> x;
vector<int> result = printnumber(x);
for (int num : result)
{
cout << num << " ";
}
cout << endl;
}
Binary file added Structures/Recursion/printcountwithoutloop.exe
Binary file not shown.

0 comments on commit c453ffd

Please sign in to comment.