mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
35 lines
623 B
Markdown
35 lines
623 B
Markdown
|
# 6-1 交换两个整数的值
|
|||
|
|
|||
|
函数fun的功能是:实现交换两个整数的值。例如给a和b分别输入3和6 ,输出为a=6 b=3。
|
|||
|
|
|||
|
### 函数接口定义:
|
|||
|
```c++
|
|||
|
void fun (int *a,int *b);
|
|||
|
```
|
|||
|
|
|||
|
其中形参`a` 和`b` 都是用户传入的参数。函数fun的功能是实现交换主函数中a和b的值。
|
|||
|
|
|||
|
### 裁判测试程序样例:
|
|||
|
```c++
|
|||
|
#include<stdio.h>
|
|||
|
void fun (int *a,int *b);
|
|||
|
int main()
|
|||
|
{ int a,b;
|
|||
|
scanf("a=%d,b=%d",&a,&b);
|
|||
|
fun(&a,&b);
|
|||
|
printf("a=%d b=%d\n",a,b);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
/* 请在这里填写答案 */
|
|||
|
```
|
|||
|
|
|||
|
### 输入样例:
|
|||
|
```in
|
|||
|
a=3,b=5
|
|||
|
```
|
|||
|
|
|||
|
### 输出样例:
|
|||
|
```out
|
|||
|
a=5 b=3
|
|||
|
```
|