【发布时间】:2017-10-05 08:29:47
【问题描述】:
我写了一个小程序。代码如下:
#include<iostream>
using namespace std;
int main()
{
int x;
float y;
cout<<"Please input an int number:"<<endl;
cin>>x;
cout<<"The input number is x= "<<endl;
cout<<"Please input a float number:"<<endl;
cin>>y;
cout<<"The float number is y= "<<endl;
return 0;
}
但是当我第一次输入数字69.8时,输出是
Please input an int number:
69.8
The int number is x= 69
The float number is y= 0.8
我以为它会把69.8转成69,然后让我输入下一个数字y,但是它自动输入,为什么?
【问题讨论】:
-
主题行与提出的问题无关。
标签: c++