主题:关于函数的一个问题
#include<iostream>
void get(int a,int b);
int main()
{
using namespace std;
int a,b;
a=5;
b=15;
cout<<"交换前:\n";
cout<<"a=:"<<a<<endl;
cout<<"b=:"<<b<<endl;
get(a,b);
cout<<"交换后:\n";
cout<<"a=:"<<a<<endl;
cout<<"b=:"<<b<<endl;
return 0;
}
void get(int a,int b)
{
int c;
c=a;
a=b;
b=c;
}
为什么运行后,交换前后结果一样?[em18]
void get(int a,int b);
int main()
{
using namespace std;
int a,b;
a=5;
b=15;
cout<<"交换前:\n";
cout<<"a=:"<<a<<endl;
cout<<"b=:"<<b<<endl;
get(a,b);
cout<<"交换后:\n";
cout<<"a=:"<<a<<endl;
cout<<"b=:"<<b<<endl;
return 0;
}
void get(int a,int b)
{
int c;
c=a;
a=b;
b=c;
}
为什么运行后,交换前后结果一样?[em18]