新手编程,一个关于while循环无法跳出的问题,请高手帮忙,谢谢。
#include<iostream>#include<cctype>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int num1=0;
int num2=0;
double average=0;
int yes_no=0;
int count=0;
while(std::tolower(yes_no)!='n')
{
cout<<"Enter a number please"<<endl;
cin>>num1;
num2+=num1;
count++;
cout<<"Do you want to enter anoter number"<<"("<<"y/n"<<")"<<endl;
cin>>yes_no;
cout<<endl;
}
average=num2/count;
cout<<"The plused number is"<<num2<<endl;
cout<<"The average number is"<<average<<endl;
return 0;
}
当输入了Y后进入死循环,cin语句不能正常执行非常郁闷。请帮忙解说下,我也能用其他语句解决,但是不知道为什么这样就不行。高手帮忙