forked from dharmanshu1921/Java
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecursion.cpp
More file actions
Latest commit
30 lines (29 loc) · 670 Bytes
/
Copy pathRecursion.cpp
File metadata and controls
30 lines (29 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
usingnamespacestd;
/* Tower of Hanoi
void TowerofHanoi(int n, char A, char B, char C)
{
if (n == 1)
{
cout << "Moving the disk from " << A << " to " << C << endl;
return;
}
TowerofHanoi(n - 1, A, C, B);
cout << "Shift disk from" << A << " to " << B << endl;
TowerofHanoi(n - 1, B, A, C);
}
int main()
{
char a = '1';
char b = '2';
char c = '3';
TowerofHanoi(3, a, b, c);
return 0;
}*/
/*Check sorted array using recursion
int checkarray(int a[], int n)
{
if (n == 1)
return;
return (a[n - 1] < a[n - 2]) ? 0 : checkarray(a, n - 1);
}*/