void fun(int *a,int *b) { int *c; c=a;a=b;b=c; } main() { int x=3,y=5,*p=&x,*q=&y; fun(p,q);...void fun(int *a,int *b){ int *c; c=a;a=b;b=c;}main(){ int x=3,y=5,*p=&x,*q=&y; fun(p,q); printf("%d,%d,",*p,*q); fun(&x,&y); prin"%d,%d\n",*p,*q);}两

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 02:39:24
voidfun(int*a,int*b){int*c;c=a;a=b;b=c;}main(){intx=3,y=5,*p=&x,*q=&y;fun(p,q);...voidfun(int*a,int*

void fun(int *a,int *b) { int *c; c=a;a=b;b=c; } main() { int x=3,y=5,*p=&x,*q=&y; fun(p,q);...void fun(int *a,int *b){ int *c; c=a;a=b;b=c;}main(){ int x=3,y=5,*p=&x,*q=&y; fun(p,q); printf("%d,%d,",*p,*q); fun(&x,&y); prin"%d,%d\n",*p,*q);}两
void fun(int *a,int *b) { int *c; c=a;a=b;b=c; } main() { int x=3,y=5,*p=&x,*q=&y; fun(p,q);...
void fun(int *a,int *b)
{
int *c;
c=a;a=b;b=c;
}
main()
{
int x=3,y=5,*p=&x,*q=&y;
fun(p,q); printf("%d,%d,",*p,*q);
fun(&x,&y); prin"%d,%d\n",*p,*q);
}

两次函数调用明明传递的是地址,为什么不能交换两个数的值

void fun(int *a,int *b) { int *c; c=a;a=b;b=c; } main() { int x=3,y=5,*p=&x,*q=&y; fun(p,q);...void fun(int *a,int *b){ int *c; c=a;a=b;b=c;}main(){ int x=3,y=5,*p=&x,*q=&y; fun(p,q); printf("%d,%d,",*p,*q); fun(&x,&y); prin"%d,%d\n",*p,*q);}两
fun中 a的值是x的地址 b的值是y的地址 记住 a和b的值也是复制过来的 然后 你把他们的值交换了 想想看和x和y的地址有什么关系呢?你在函数中 应该用int c;c=*a;*a=*b;*b=c;
这样就通过地址修改了地址中的值

void fun(int *a,int n) { int i,j,k,t; for(i=0;i #include void fun(int a[],int n) { int i,t; for(i=0;i void main() {int t=1;fun(fun(t));} fun(int h) {stvoid main(){int t=1;fun(fun(t));}fun(int h){static int a[3]={1,2,3}; int k; for(k=0;k #include int inc(int a){ return(++a); }int multi(int*a,int*b,int*c){ return(*c=*a**b); }typedef int(FUNC1)(int in);typedef int(FUNC2) (int*,int*,int*);void show(FUNC2 fun,int arg1,int*arg2){FUNC1 p=&inc;int temp =p(arg1);fun(&temp,&arg1,arg2);printf( 下列各个成员函数中,纯虚函数是( ) A.void fun(int)=0 B.virtual void fun(int) C.virtual void fun #include int inc(int a) { return(++a); } int multi(int*a,int*b,int*c) { return(*c=*a**b); }typedef int(FUNC1)(int in);  typedef int(FUNC2) (int*,int*,int*);  void show(FUNC2 fun,int arg1,int*arg2)  {  INCp=&inc;  int temp =p(arg1) void fun(int p) { int d=2; p=d++; printf(%d,p); } main() { int a=1; fun(a); printf(%d ,a); } #include void fun(int p) { int d=2; p=d++; printf(“%d”,p);} main() { int a=1; fun(a); printf(“%d 下面的这个是参考答案上的程序# include void fun(int (*str)[10],int *a,int *n,int mm,int nn){int i,j;for(j=0;j void fun(int a[][N],im b[]),这是什么,在主函数中没引用啊 void fun(int a,int b) { int t; t=a;a=b;b=t; } main()void fun(int a,int b){ int t; t=a;a=b;b=t; } main() { int c[10]={1,2,3,4,5,6,7,8,9,0}.i; for(i=0;i STU*fun(STU a[],int void fun(int *a,int *b) { int *c; c=a;a=b;b=c; } main() { int x=3,y=5,*p=&x,*q=&y; fun(p,q);...void fun(int *a,int *b){ int *c; c=a;a=b;b=c;}main(){ int x=3,y=5,*p=&x,*q=&y; fun(p,q); printf(%d,%d,,*p,*q); fun(&x,&y); prin%d,%d ,*p,*q);}两 求此题解题过程:#include #define N 8 void fun(int *x,int i) {*x=*(x+i);} main() {int a[N] #include int b=3; int fun(int *a) { b+=*a; return(b); }void main(){ int a=2,b=2;b+=fun(&a);printf(“%d ”,b);读程序写出程序执行结果 #define N 20 fun(int a[],int n,int m) {int i; for(i=m;i>n;i--)a[i+1]=a[i]; return m; } void main() #define N 20fun(int a[],int n,int m){int i;for(i=m;i>n;i--)a[i+1]=a[i];return m;}void main(){ int i,a[N]={1,2,3,4,5,6,7,8,9,10};fun(a,0,N/2);for(i=0;i #include int d=1; void fun (int p) { int d=5 ; d+=p++; printf( %d ,d ) ; }main (){ int a=3 ;fun(a);d+=a++;printf(%d ,d );} 函数调用 参数的传递void fun(int){ cout