#include<stdio.h>
#pragma warning(disable:4996)
int fun(int x[],int n,int e,int*num)
{int i=0 ,sum1=0;
for(i=0;i<n;i++)
if(x[i]%e==0)
{sum1+=x[i];*num++;}
return sum1;
}
int main()
{ int x[]={1,9,8,6,12},num=0,sum;
sum=fun(x,5,3,&num);
printf("sum=%d,num=%d\n",sum,num);
}
为什么改了一种表达方式执行结果却不一样了,num++不是与num=num+1表达的是一样的吗
#include<stdio.h>
#pragma warning(disable:4996)
int fun(int x[],int n,int e,int*num)
{int i=0 ,sum1=0;
for(i=0;i<n;i++)
if(x[i]%e==0)
{sum1+=x[i];*num=*num+1;}
return sum1;
}
int main()
{ int x[]={1,9,8,6,12},num=0,sum;
sum=fun(x,5,3,&num);
printf("sum=%d,num=%d\n",sum,num);
}