Fandy_Chen
Fandy_Chen
2016-02-20 02:06

C++问题, 为什么输入0.99会进入死循环

  • c++

在学习C++时调试这段代码在month 输入**小于1的小数**时,进入死循环,还请大神帮忙解释一下,感谢

int userYear, userMonth;
cout<< "Please input year:"<<endl;
cin >> userYear;

cout<<"Please input month:"<<endl;
cin >> userMonth;

while(userMonth > 12 || userMonth < 1){
    cout<<"The month is not legal, Please input again: "<<endl;
    cin >> userMonth;
}
![图片说明](https://img-ask.csdn.net/upload/201602/20/1455933865_719630.png)
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答