ALL > Computer and Education > courses > university courses > undergraduate courses > An Overview of Computer Science > 2017-2018-1 class > 2017329621007范佳函 >
homework-5 Version 0
👤 Author: by 583256193qqcom 2017-11-23 16:48:16
#40.recursive one

#include <stdio.h>
 

 void move(int n, char x, char y, char z)   
 {
      if(n == 1)
        printf("move ring %d from %c to %c\n",n,x,z);
      else
      {
     move(n-1,x,y,z);
         printf("move ring %d from %c to %c\n",n,x,z);
         move(n-1,y,x,z);
      }
 
 }
 
 int main()
 {
     //A,B,C represents three pegs
     char ch1 = 'A';
     char ch2 = 'B';
 

Please login to reply. Login

Reversion History

Loading...
No reversions found.