oid swap1(int c[ ]) { int t; t=c[0];c[0]=c[1];c[1]=t; } void swap2(int c0, int c1) { int t; t=c0;c0

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 23:35:41
oid swap1(int c[ ]) { int t; t=c[0];c[0]=c[1];c[1]=t; } void swap2(int c0, int c1) { int t; t=c0;c0

oid swap1(int c[ ]) { int t; t=c[0];c[0]=c[1];c[1]=t; } void swap2(int c0, int c1) { int t; t=c0;c0
oid swap1(int c[ ]) { int t; t=c[0];c[0]=c[1];c[1]=t; } void swap2(int c0, int c1) { int t; t=c0;c0

oid swap1(int c[ ]) { int t; t=c[0];c[0]=c[1];c[1]=t; } void swap2(int c0, int c1) { int t; t=c0;c0
大哥 ,题目不全啊.原题:
#include "stdio.h"
void swap1(int c[ ])
{ int t;
t=c[0];c[0]=c[1];c[1]=t;
}
void swap2(int c0,int c1)
{ int t;
t=c0;c0=c1;c1=t;
}
main( )
{ int a[2]={3,5},b[2]={3,5};
swap1(a); swap2(b[0],b[1]);
printf("%d %d %d %d\n",a[0],a[1],b[0],b[1]);
}
因为第一个交换传的是地址,所以能交换成功,而第二个是传值,就是拷贝一份数据传过去,而实参没有改变,所以交换不成功.输出为 5 3 3 5