阅读下面的程序:
main()
{ int swap();
int a,b;
a=3;b=10; swap(a,b);
printf("a=%d,b=%d
",a,b); }
swap(int a,int b)
{ int temp;
temp=a; a=b; b=temp; }
下面的说法中,正确的是________
main()
{ int swap();
int a,b;
a=3;b=10; swap(a,b);
printf("a=%d,b=%d
",a,b); }
swap(int a,int b)
{ int temp;
temp=a; a=b; b=temp; }
下面的说法中,正确的是________
举一反三
- void swap(int, int); void main(){int a=3,b=5; printf(“a=%d, b=%d”,a,b); swap(a, b); printf(“a=%d, b=%d”,a,b); } void swap(int x, int*y); {int temp = x; x=y; y=temp;} 这段程序计算结果是
- 写出下列程序运行结果 #include “stdio.h” void swap(int *px , int *py ); void main() { int a,b; a=5; b=10; printf(“ before swap a=%d, b=%d ”,a,b); swap(&a,&b); printf(“after swap a=%d, b=%d ”,a,b); } voidswap(int *px , int *py ) { int temp; temp=*px; *px=* py; *py=temp; printf(“ in swap x=%d,y=%d ”,*px, *py); }
- 以下程序的输出结果是()。 #include void swap(int x[2]) { int temp; temp = x[0]; x[0] = x[1]; x[1] = temp; } int main() { int a[2]={3,5}; swap(a); printf("%d %d\n",a[0],a[1]); return 0; } A: 3 5 B: 5 3 C: 3 3 D: 5 5
- 有如下函数定义:void swap(int x,int y) { int temp; temp=x; x=y; y=temp; }在运行如下语句后, a=1;b=2; swap(a,b);a的值为 。
- 以下程序的运行结果为( )void swap(int x[]){ int temp; temp = x[0]; x[0] = x[1]; x[1] = temp;}void main(){ int a[2]={3,5}; swap(a); printf("a[0]=%d\na[1]=%d\n",a[0],a[1]);}