一个do while 问题
小弟刚开始学习C语言,请问各位我的程序执行到printf("\n Want to play again?y/n:");为什么会直接跳出程序 ,而不再要求我输入Y/y#include "stdio.h"
main()
{
int n;
char x;
void hanoi(int n,char a,char b,char c);
printf("\n *********************************************************");
printf("\n * * * Program for simulating the solution * * *");
printf("\n * * * of the game of tower of hanoi, * * *");
printf("\n *********************************************************");
printf("\n =========================================================");
do{
printf("\n Please enter the number of discs to be moved:");
scanf("%d",&n);
hanoi(n,'a','b','c');
printf("\n Want to play again?y/n:");
scanf("%c",&x);
}while(x=='y'||x=='Y'); /*为什么不能循环*/
}
void hanoi(int n,char a,char b,char c) /* 汉诺塔问题,永远的递归*/
{
if(n>0)
{
hanoi(n-1,a,c,b);
printf("\n Move disc %d form pile %c to %c",n,a,b);
hanoi(n-1,c,b,a);
}
}