给定两个整形变量,交换他们的数值。

#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
int main()
{
	int a = 1;
	int b = 2;
	int c = 0;//定义中间值
	scanf("%d %d ", &a, &b);
	{
		c = a;
		a = b;
		b = c;
	}
	printf("a = %d b = %d\n", a, b);
	system("pasue");//暂停代码
	Sleep(10000);//睡眠 为了更好的看清代码
	return 0;
}

猜你喜欢

转载自blog.csdn.net/HuiDiExAg/article/details/89337383