#include
int averag(int a[])
{
int *p,sum=0;
p=a;
for(int i=0;i<9;i++)
{
sum+=*p;
p++;
}
return sum/9;
}
void main()
{
int a[9]={3,5,7,1,9,4,6,2,8};
int s=averag(a);
printf("%d",s);
}
已调试通过,不会hi我
//应该是这样吧
#include
float getave(int *a,int n);
void main()
{
int a[9] ={3,5,7,1,9,4,6,2,8};
float average;
average = getave(a,9);
printf("平均分为:%.2f\n",average);
}
//所要函数
float getave(int *a,int n)
{
float sum=0;
int i;
for(i=0;i
sum +=a[i];
}
return sum/n;
}
#include"stdio.h"
average(int *a)
{
int m=0,i;
for(i=0;i<9;i++)
m+=*(a+i);
return (m/9);
}
main()
{
int a[9]={3,5,7,1,9,4,6,2,8},av;
av=average(a);
printf("输出结果为%d\n",av);
}
搞定;
main
{
double average;
int n;
int a[9]={3,5,7,1,9,4,6,2,8};
n=9
average=CalAverage(a,n);
printf("%f",average);
}
double CalAverage(int * a,int n)
{
double total;
double average;
int i;
total=0;
for(i=0;i
total=total+a[i];
}
average=total/n;
return(average);
}
调试下,应该差不多了。
#include
#include
double average(int *a,int n);
void main()
{
int a[9]={3,5,7,1,9,4,6,2,8};
double ave=average(a,9);
printf("%f\n",ave);
}
double average(int *a,int n)
{
double sum=0,ave=0;
for(int i=0;i
ave=sum/n;
return ave;
}
#include
#include
using namespace std;
float avg(int *p)
{
int i;
float sum=0;
for(i=0;i<9;i++,p++)
sum+=*p;
return sum/9;
}
int main()
{
int a[9]={3,5,7,1,9,4,6,2,8};
int *p=a;
cout<
}