20191213引用

#include<Windows.h>
#include <iostream>
using namespace std;
//引用作为函数的形参时,不需要进行初始化
int swap(int& x, int& y) {
	int temp = x;
	x = y;
	y = temp;
	return 0;
}
int main() {
	int a = 100;
	int b = 10;
	swap(a, b);
	printf_s("a=%d,b=%d", a, b);

	system("pause");
	return 0;
}

函数功能实现了数据的交换,运行结果如图
在这里插入图片描述

发布了51 篇原创文章 · 获赞 0 · 访问量 541

猜你喜欢

转载自blog.csdn.net/weixin_40071289/article/details/103533117