使用中间变量交换两个变量的值
int a = 10 , b = 11 , m; m = a; a = b; b = m;
不使用中间变量交换两个变量的值
int a = 10; int b = 11; a = a + b; b = a - b; a = a - b;
时间: 2024-10-10 21:30:31
使用中间变量交换两个变量的值
int a = 10 , b = 11 , m; m = a; a = b; b = m;
不使用中间变量交换两个变量的值
int a = 10; int b = 11; a = a + b; b = a - b; a = a - b;