假设变量a,b初始值为4,5,通过swap(a,b)可以实现a和b值互换的函数定义为( D )
(A)void swap(int p1,int p2){int tmp; tmp=*p1; *p1=*p2; *p2=tmp;}
(B)void swap(int *p1,int *p2){int *tmp; *tmp=*p1; *p1=*p2; *p2=tmp;}
(C)void swap(int p1,int p2){int tmp; tmp=p1; p1=p2; p2=tmp;}
(D)void swap(int *p1,int *p2){int tmp; tmp=*p1; *p1=*p2; *p2=tmp;}
(A)void swap(int p1,int p2){int tmp; tmp=*p1; *p1=*p2; *p2=tmp;}
(B)void swap(int *p1,int *p2){int *tmp; *tmp=*p1; *p1=*p2; *p2=tmp;}
(C)void swap(int p1,int p2){int tmp; tmp=p1; p1=p2; p2=tmp;}
(D)void swap(int *p1,int *p2){int tmp; tmp=*p1; *p1=*p2; *p2=tmp;}