展开全部
#include<iostream>
using namespace std;
int Average(int num[])
{
int ave=0;
for(int i=0;i<5;i++)
ave+=num[i];
return ave/5;
}
float Average(float num[])
{
float ave=0.0;
for(int i=0;i<5;i++)
ave+=num[i];
return (ave/5.0);
}
void main(void)
{
cout<<"Input 5 (int Type)numbers:";
int i, num1[5]={0};
for(i=0;i<5;i++)
cin>>num1[i];
cout<<"The average of the numbers(int) is:"<<Average(num1)<<endl;
////////////////////////////
cout<<"Input 5 (float Type)numbers:";
float num2[5]={0.0};
for( i=0;i<5;i++)
cin>>num2[i];
cout<<"The average of the numbers(float) is:"<<Average(num2)<<endl;
}
using namespace std;
int Average(int num[])
{
int ave=0;
for(int i=0;i<5;i++)
ave+=num[i];
return ave/5;
}
float Average(float num[])
{
float ave=0.0;
for(int i=0;i<5;i++)
ave+=num[i];
return (ave/5.0);
}
void main(void)
{
cout<<"Input 5 (int Type)numbers:";
int i, num1[5]={0};
for(i=0;i<5;i++)
cin>>num1[i];
cout<<"The average of the numbers(int) is:"<<Average(num1)<<endl;
////////////////////////////
cout<<"Input 5 (float Type)numbers:";
float num2[5]={0.0};
for( i=0;i<5;i++)
cin>>num2[i];
cout<<"The average of the numbers(float) is:"<<Average(num2)<<endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询