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/06/29 02:24:12
![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](/uploads/image/z/9860620-4-0.jpg?t=oid+swap1%28int+c%5B+%5D%29+%7B+int+t%3B+t%3Dc%5B0%5D%3Bc%5B0%5D%3Dc%5B1%5D%3Bc%5B1%5D%3Dt%3B+%7D+void+swap2%28int+c0%2C+int+c1%29+%7B+int+t%3B+t%3Dc0%3Bc0)
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