1) count_down(count-1); printf("B%d\n", count); main (){ count_down(4); } Recursion 遞歸 3 Recursion A4 B A3 B3 A2 B2 A1 B1"> 1) count_down(count-1); printf("B%d\n", count); main (){ count_down(4); } Recursion 遞歸 3 Recursion A4 B A3 B3 A2 B2 A1 B1">
Download presentation
Presentation is loading. Please wait.
Published byJosie Hendrickson Modified over 9 years ago
1
5432154321 void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n", count); main (){ count_down(5); } A5 A4 A3 A2 A1 Recursion 遞歸 1 Recursion A5 count_down(4); B5 A4 count_down(3); B4 A3 count_down(2); B3 A2 count_down(1); B2 B1 B2 B3 B4 B5 A1 B1
2
countDown(4) countDown(3) printf("A%i", count); printf("B%i", count); countDown(2) printf("A%i", count); printf("B%i", count); countDown(1) printf("A%i", count); printf("B%i", count); A4 A3 A2 printf("A%i", count); printf("B%i", count); countDown(?) A1 B1 B2 B3 B4 2 Recursion A4 A3 A2 A1 B1 B2 B3 B4
3
void count_down (int count) { } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n", count); main (){ count_down(4); } Recursion 遞歸 3 Recursion A4 B4 4 3 2 1 A3 B3 A2 B2 A1 B1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.