#include<iostream>
const int max = 5;
int main()
{
using namespace std;
//get data
int golf[max];
cout<<"please enter a number:\n";
cout<<"请输入5次"<<endl;
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 enter a number:";
}
}
//calculate total
double total = 0.0;
for (i=0;i<max;i++)
total+=golf[i];
cout<<total/max<<"= average"<<endl;
//report average
return 0;
}
6.14
最新推荐文章于 2024-10-29 19:22:12 发布