题目是一维数组放10个数,输入2下标数m,n,从数组m加到数组n求和,用指针
#include"stdio.h"int sum(int *p,int z)
{ int i,s=0;
for(i=0;i<=z;i++,p++)
{s+=*p;}
return s;}
int main(){
int a[10]={1,2,3,4,5,6,7,8,9,10 };
int *x,m,n,z;
printf("input n and m like n m:\n");
scanf("%d %d",&n,&m);
x=a+n-1;
z=m-n;
printf("the sum is:",sum(x,z));
}
咋输出什么都没呢?求问题出在哪里???