7.2

#include<iostream>

void shuru(double ar[],int number);
void show(double ar[],int number);
double average(double ar[],int number);

int main()
{
	double a[10];
	int number;
	std::cout<<"enter number: ";
	std::cin>>number;
	shuru(a,number);
	show(a,number);
	std::cout<<average(a,number);
	system("pause");
	return 0;
}
void shuru(double ar[],int number)
{
	
	for(int i=0;i<number;i++)
		std::cin>>ar[i];
}
void show(double ar[], int number)
{
	for(int i=0;i<number;i++)
		std::cout<<ar[i]<<" ";
	std::cout<<std::endl;
}
double average(double ar[],int number)
{
	double average=0;
	for(int i =0;i<number;i++)
	{
		average+=ar[i];
	}
	return (average/=number);
}

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页