编写一个C程序,输入两个整数a,b,交换a和b的数值,然后输出
时间: 2023-04-10 08:04:38 浏览: 71
以下是 ChatGPT 的回答:
可以使用以下代码实现:
#include <stdio.h>
int main() {
int a, b, temp;
printf("请输入两个整数:\n");
scanf("%d%d", &a, &b);
temp = a;
a = b;
b = temp;
printf("交换后的数值为:%d %d\n", a, b);
return 0;
}
相关问题
编写一个c程序,输入两个整数a,b,交换a和b的数值,然后输出
#include <stdio.h>
int main()
{
int a, b, temp;
printf("请输入两个整数:");
scanf("%d %d", &a, &b);
temp = a;
a = b;
b = temp;
printf("交换后的值为:a = %d, b = %d\n", a, b);
return 0;
}
编写一个C程序,输入两个整数ab,交换ab的数值然后输出
好的,以下是代码:
```c
#include <stdio.h>
int main() {
int a, b, temp;
printf("请输入两个整数:\n");
scanf("%d%d", &a, &b);
temp = a;
a = b;
b = temp;
printf("交换后的数值为:%d %d\n", a, b);
return 0;
}
```
希望能帮到您!
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)