20191210 使用指针实现数据的交换

使用函数,配合着指针实现数据的交换,萌萌的!

#include <Windows.h>
#include <iostream>

using namespace std;
int swap(int* a, int* b) {
	int temp = *a;
	*a = *b;
	*b = temp;
	return 0;
}

int main() {
	int x = 10, y = 100;
	swap(&x, &y);
	printf_s("x=%d,y=%d\n", x, y);
	system("pause");
	return 0;
}

配上图:
在这里插入图片描述

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

猜你喜欢

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