#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void hanoi(int 盤數,int 初,int 補,int 終){
if(盤數==1)
printf("%d>%d\n",初,終);
else{
hanoi(盤數-1,初,終,輔);
printf("%d>%d\n",初,終);
hanoi(盤數-1,輔,初,終);
}
}
int main(){
int 盤;
srand(time(NULL));
盤=rand()%;
printf("柱一=1,柱二=2,柱三=3\n盤數=%d\n",盤);
hanoi(盤數,1,2,3);
system ("pause");
return 0;
} |