这是转载的老师发的答案哦,放心使用,关注我,随时更新新的答案,侵权联系删
#include <iostream>
using namespace std;
int average(int, int);
static const int EXIT = 9999;
int main()
{
int counter{0};
int sum{0};
cout <<"Enter a list of space separated integers for average calculation."<< EXIT <<"ends input"<<endl;
cin >> sum;
for (int i = 0;i != EXIT;++counter)
{
sum += i;
cin >> i;
}
cout << "Average of sum: " << average(sum, counter) << endl;
return 0;
}
int average(int a, int b)
{
return (a / b);
}