#include <stdio.h>
#define SIZE 5
void modifyArray (int [],int);
void modifyElement(int);
void main()
{
int a[SIZE]={0,1,2,3,4};
int i;
printf("Effects of passing array call"
" by reference:/n/nThe values of the"
"original arry are:/n");
for(i=0;i<=SIZE-1;i++)
printf("%3d",a[i]);
printf("/n");
modifyArray(a,SIZE); //以传引用方式传递数组a
printf("The values of the modify are:/n");
for(i=0;i<=SIZE-1;i++)
printf("%3d",a[i]);
printf("/n/n/nElements of passing array element call"
"by value:/n/nThe value of a[3] is %d/n",a[3]);
modifyElement(a [3]);
printf("The value of a [3] is %d/n/n",a[3]);
return 0;
}
void modifyArray(int b[], int size)
{
int j;
for(j=0;j<=size-1;j++)
b[j]*=2;
}
void modifyElement(int e)
{
printf("Value is modifyElement is %d/n",e*=2);
}
哈哈,上机就是一种享受.真的.这个题在下面看了
几次也没有明白,一来上几就明白拉.
只可惜我的工具不怎么好,学校的图书馆的机房的
机子没有VC,那我只好用TOUBER C ,汗!
虽然效率是低了点,但能上机操作就已经可以了.