1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】13.指针1/6-1 交换两个整数的值.md

35 lines
623 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
```