Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- void dichchuyen(int n, int C1, int C2, int C3);
- void main()
- {
- int n, C1=1,C2=2,C3=3;
- printf(" so dia la : ");
- scanf_s(" %d ", &n);
- dichchuyen(n, 1, 2, 3);
- system("PAUSE");
- }
- void dichchuyen(int n, int C1, int C2, int C3)
- {
- if (n == 1)
- printf("%d --> %d \n", C1, C2);
- else
- {
- dichchuyen(n - 1, C1, C3, C2);
- dichchuyen(1, C1, C2, C3);
- dichchuyen(n - 1, C3, C2, C1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment