帮忙下,数组的问题!!!
#include<iostream>#include<cstring>
const int limit=10;
int shur(int arr[],int size);
double avg(int arr[],int size);
void show(int arr[],int size);
int main()
{
using namespace std;
int golf[limit];
int n;
n=shur(golf,limit);
double a;
a=avg(golf,n);
show(golf,n);
cout<<n<<endl;
cout<<a<<endl;
return 0;
}
int shur(int arr[],int size)
{
using namespace std;
int temp;int i=0;
cin>>temp;
while(i<size&&isdigit(temp))
{
cout<<"enter......\n";
arr[i]=temp;
i++;
cin>>temp;
}
return i;
}
double avg(int arr[],int size)
{
int sum=0;
for(int i=0;i<size;i++)
{
sum+=arr[i];
}
return sum/size;
}
void show(int arr[],int size)
{
using namespace std;
for(int j=0;j<size;j++)
{
cout<<arr[j]<<endl;
}
}