ACdream 1001 整数交换

来源:互联网 发布:经典文案 知乎 编辑:程序博客网 时间:2024/06/06 17:47

Problem Description

写一个函数用于交换两个整数变量的值。【题目只需要提交SwapInt的函数实现】

Input

请用C++实现下面的函数。
void SwapInt(int *a,int *b); //功能说明:交换形参a,b所指向变量的值。

Output

Sample Input

调用示例:
int a = 3,b = 5;
SwapInt(&a,&b);

Sample Output

调用结果:
a的值变成5,b的值变成3

code

/** this code is made by linglian* Problem: 1001* Verdict: Accepted* Submission Date: 2017-05-05 20:24:58* Time: 12MS* Memory: 1084KB*/void SwapInt(int *a,int *b) {    *a += *b;    *b = *a - *b;    *a -= *b;}
0 0