#include<stdio.h>
int addArray(int array[],int n);
int main(void)
{
int date[]={0,1,2,3,4,5,6,7,8,9};
int size=sizeof(date)/sizeof(date[0]);
printf("结果是:%d\n",addArray(date,size));
return 0;
}
int addArray(int array[],int n)
{
int sum=0;
int i;
for(i=0;i<n;i++)
sum+=array[i];
return sum;
}
//或者
#include <stdio.h>
int main (void)
{
int num[5]={5,6,7,8,9};
int i=0,sum=0;
for(;i<5;i++)
{
sum+=num[i];
}
printf("∑为:%d\n",sum);
return 0;
}