#include<iostream>
using namespace std;
int input(double *, int);
void show(const double *, int);
double mean(const double *, int);
const int max = 3;
int main(){
double golf[max];
double amean;
int size;
size = input(golf, max);
show(golf, size);
amean = mean(golf, size);
cout << amean << endl;
system("PAUSE");
}
int input(double golf[], int max){
int i = 0;
double agolf;
for (i = 0; i < max; i++){
cout << "Enter your pointer: ";
cin >> agolf;
if (!cin){
cin.clear();
while (cin.get() != '\n')
continue;
cout << "Bad input: input process terminated.\n";
break;
}
else if (agolf < 0)
{
break;
}
golf[i] = agolf;
}
return i;
}
void show(const double golf[], int size){
for (int i = 0; i < size; i++){
cout << golf[i] << endl;
}
}
double mean(const double golf[], int size){
double sum = 0;
for (int i = 0; i < size; i++)
sum += golf[i];
double mean = sum / size;
return mean;
}
using namespace std;
int input(double *, int);
void show(const double *, int);
double mean(const double *, int);
const int max = 3;
int main(){
double golf[max];
double amean;
int size;
size = input(golf, max);
show(golf, size);
amean = mean(golf, size);
cout << amean << endl;
system("PAUSE");
}
int input(double golf[], int max){
int i = 0;
double agolf;
for (i = 0; i < max; i++){
cout << "Enter your pointer: ";
cin >> agolf;
if (!cin){
cin.clear();
while (cin.get() != '\n')
continue;
cout << "Bad input: input process terminated.\n";
break;
}
else if (agolf < 0)
{
break;
}
golf[i] = agolf;
}
return i;
}
void show(const double golf[], int size){
for (int i = 0; i < size; i++){
cout << golf[i] << endl;
}
}
double mean(const double golf[], int size){
double sum = 0;
for (int i = 0; i < size; i++)
sum += golf[i];
double mean = sum / size;
return mean;
}