C++第一次作业01
1、 利用引用做形参编写一个函数实现两个整数的交换。
#include <iostream>
using namespace std;
void swap(int &a,int &b)
{
int t;
t = a;
a = b;
b = t;
}
int main()
{
int x(1),y(2);
cout <<"x = "<<x;
cout <<" y = "<<y<<"\n";
swap(x,y
原创
2020-09-08 22:12:02 ·
168 阅读 ·
0 评论