#include<stdio.h>
int sum(int *q,int n)
{ int i,s=0;
for(i=0;i<n;i++,q++)
s+=*q;
return s;
}
void main()
{ int num,a[10]={1,2,3,4,5,6,7,8,9,10};
int *p=a;
scanf("%d",&num);
printf("%d\n",sum(p,num));
}
编程题:指针变量,实参与形参的引用。已知一个一维数组,求其中前n个数的和。n由键盘输入。,布布扣,bubuko.com
时间: 2024-10-08 17:18:37