1 / 3

5 4 3 2 1

Recursion 遞歸. 5 4 3 2 1. A5 A4 A3 A2 A1. void count_down ( int count) { for( i =count; i &gt;1; i --) printf (&quot; %dt&quot;, count); }. printf (&quot; A %d <br>&quot;, count ); if(count&gt;1) count_down (count-1); printf (&quot; B %d <br>&quot;, count );. A 5 count_down (4); B 5. A 4 count_down (3);

Télécharger la présentation

5 4 3 2 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recursion 遞歸 5 4 3 2 1 A5 A4 A3 A2 A1 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); A5 count_down(4); B5 A4 count_down(3); B4 B1 B2 B3 B4 B5 A3 count_down(2); B3 A2 count_down(1); B2 A1 B1 main (){ count_down(5); }

  2. countDown(4) A4 A3 A2 A1 printf("A%i", count); A4 countDown(3) printf("B%i", count); B4 B1 B2 B3 B4 printf("A%i", count); A3 countDown(2) printf("B%i", count); B3 printf("A%i", count); A2 countDown(1) printf("B%i", count); B2 printf("A%i", count); A1 countDown(?) B1 printf("B%i", count);

  3. 1 A4 Recursion 遞歸 2 3 A3 4 A2 void count_down (int count) { } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n", count); A1 B1 B2 main (){ count_down(4); } B3 B4

More Related