下面程序的运行结果为
#include<iostream.h>
void swap(int &a, int b)
{
int temp;
temp=a++;
a=b;
b=temp;
}
void main( )
int a=2,b=3;
swap(a, b) ;
cout < < a < <"," < < b < < endl;
}
A.2,3
B.3,2
C.2,2
D.3,3
第1题:
下面程序输出的结果是( )。 #include <iostream> using namespace std; void swap(int &a,int &b){ int temp; temp=a; a=b; b=temp; } void main(){ int x=2; int y=3; swap(x,y); cout<<x<<y; }
A.23
B.32
C.ab
D.ba
第2题:
下面程序的运行结果为( )。 #include<iostream.h> void swap(int&a,int B. int temp; temp=a++: a=b: b=temp; } void main { im a=2,b=3; swap(a,B.; eout<<a<<”,”<<b<<endl; }
A.2,3
B.3,2
C.2,2
D.3,3
第3题:
可以交换两个数的函数定义为: void swap(int *p,int *q) { int *temp; *temp=*p; *p=*q; *q=*temp; }
第4题:
下面程序的运行结果为( )。#include<iostream.h>
voidswap(int&a,intb)
{
int temp;
temp=a++;
a=b:
b=temp:
}
voidmain()
{
inta=2,b=3;
swap(a,b);
cout<<a<<","<<b<<endl;
}
A.2,3
B.3,2
C.2,2
D.3,3
A.2,3
B..3,2
C.2,2
D.3,3
第5题:
下面程序的运行结果为( )。#include<iostream.h>void swap (int &a, int b){int temp;temp=a++;a=b;b=temp;}void main(){int a=2, b=3;swap(a,b);cout<<a<<","<<b<<end1;}
A.2,3
B.3,2
C.2,2
D.3,3