菜鸟问题!cin未被执行!
#include<vector>#include<algorithm>
#include<iostream>
using namespace std;
void main()
{
cout<<"请输入数据!"<<endl;
double x;
vector<double> data;
while (cin>>x)
{
data.push_back(x);
}
int m=data.size(),n=0;
if (m==0)
{
throw domain_error("数据不能为空!");
}
else
{
double number;
cout<<"请输入你要找的数!"<<endl;
cin>>number; //此处未被执行!!
for (int i=0;i<m ;i++)
{
if (number==data[i])
{
n++;
}
}
if (n==0)
{
cout<<"没有你要找的数"<<endl;
}
else
{
cout<<number<<"有"<<n<<"个"<<endl;
}
}
}
请高手指教!!!有bug待完善!!