![]() |
#2
quietstar2010-03-08 18:20
|

#include<iostream>
using namespace std;
const int max=5;
int main()
{
int golf[max];
cout<<"please input your golf scores.\n";
cout<<"you must enter "<<max<<" rounds.\n";
int i;
for(i=0;i<max;i++)
{
cout<<"round #"<<i+1<<":";
while(!(cin>>golf[i]))
{
cin.clear();//为什么我删除这行后,输入非数字后,无法再输入
while(cin.get()!='\n')
continue;
cout<<"please input a number:\n";
cout<<"round #"<<i+1<<":";
}
}
return 0;
}
using namespace std;
const int max=5;
int main()
{
int golf[max];
cout<<"please input your golf scores.\n";
cout<<"you must enter "<<max<<" rounds.\n";
int i;
for(i=0;i<max;i++)
{
cout<<"round #"<<i+1<<":";
while(!(cin>>golf[i]))
{
cin.clear();//为什么我删除这行后,输入非数字后,无法再输入
while(cin.get()!='\n')
continue;
cout<<"please input a number:\n";
cout<<"round #"<<i+1<<":";
}
}
return 0;
}