ACdream 1001 整数交换

xiaoxiao2021-02-28  99

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; }
转载请注明原文地址: https://www.6miu.com/read-38741.html

最新回复(0)