正在加载图片...
清华大学出版社 TSINGHUA UNIVERSITY PRESS void swap(int x, int y) void swap2(int *p) void swap 3(int *pl, int*p2) i int temp i int temp t int *temp temp=X temp=p temp-=pl; y p=*(p+1) pI=p2 y=temp (p+1)=temp 2=temp; void main () inta={3,5},b[]={3,5},c[]={3,5} swapl(a[o, a[lD; swap2(b); swap(&c[o], &cllD) printf( %d, %odn%d, %dn%d, %od,, a[ol, a[ll,blo,blll clo] cllD 数组元素作参数是将数组元素的值传递到形参对应的内存空间中, 数组名作参数是将数组名的值(即数组首地址)传递到形参对应的单元中void swap1(int x, int y) void swap2(int *p) void swap3(int *p1,int *p2) { int temp; { int temp; { int *temp; temp=x; temp=*p; temp= p1; x=y; *p=*(p+1); p1 = p2; y=temp; *(p+1)=temp p2=temp; } } } void main() { int a[]={3,5}, b[ ]={3,5}, c[ ]={3,5}; swap1 (a[0], a[1]); swap2 (b); swap3 (&c[0],&c[1]); printf(“%d,%d\n%d,%d\n%d,%d\n” ,a[0],a[1],b[0],b[1],c[0],c[1]); } 数组元素作参数是将数组元素的值传递到形参对应的内存空间中, 数组名作参数是将数组名的值(即数组首地址)传递到形参对应的单元中
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有