ALL > Computer and Education > courses > university courses > undergraduate courses > An Overview of Computer Science > 2017-2018-1 class > student homework directory >
homework 5 2017329621012曹秋斌 Version 0
👤 Author: by 283385508qqcom 2017-11-23 14:32:27
#include<stdio.h>
void han(int n,char a,char c,char b)
{
if(n==1){
printf("第%d块盘子:%c----%c\n",n,a,c);
return;
}

han(n-1,a,b,c);
printf("第%d块盘子:%c----%c\n",n,a,c);
han(n-1,b,c,a);
}
int main(){
int n;

scanf("%d",&n);
han(n,'A','C','B');
return 0;
}

Please login to reply. Login

Reversion History

Loading...
No reversions found.