#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int total = 0;
int counter;
double average;
int a=0; //a代表输入值
cout << "Enter(9999 to quit):"<<endl;
//此行为输入一个值,进行判断
cin >> a;
for ( counter = 1; a != 9999; ++counter )
{
total += a;
cin >> a;
//average = static_cast< double >( total )/counter;
}
average = static_cast< double >( total )/(counter-1);
cout << " The average is:" << average << endl;
system("pause");
return 0;
}
using std::cout;
using std::cin;
using std::endl;
int main()
{
int total = 0;
int counter;
double average;
int a=0; //a代表输入值
cout << "Enter(9999 to quit):"<<endl;
//此行为输入一个值,进行判断
cin >> a;
for ( counter = 1; a != 9999; ++counter )
{
total += a;
cin >> a;
//average = static_cast< double >( total )/counter;
}
average = static_cast< double >( total )/(counter-1);
cout << " The average is:" << average << endl;
system("pause");
return 0;
}