阅读98 返回首页    go 阿里云 go 技术社区[云栖]


swap() 交换两个数

#include <stdio.h>

void swap(int *x, int *y)//传入指针
{
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

int main()
{
	int a = 3;
	int b = 5;
	printf("a = %d, b = %d\n", a, b);
	swap(&a, &b);
	printf("a = %d, b = %d\n", a, b);
	return 0;
}


最后更新:2017-04-03 16:48:53

  上一篇:go 应该知道的c知识点
  下一篇:go 什么是网站开发?