#include<stdio.h>
int main()
{
void swap(int* p1, int* p2);
int a, b, c;
printf("Please input three integers: ");
scanf_s("%d%d%d", &a, &b, &c);
swap(&a, &b);
swap(&a, &c);
swap(&b, &c);
printf("The ascending order is %d %d %d\n", a, b, c);
return 0;
}
void swap(int* p1, int* p2)
{
if (*p1 > *p2) {int t = *p1;*p1 = *p2;*p2 = t;}
}
void swap(int*p1,int*p2)排序
本文展示了如何在C语言中使用自定义函数`swap`对三个输入整数进行升序排序的过程。用户首先输入三个整数,然后调用`swap`函数交换并最终输出排序结果。
6372

被折叠的 条评论
为什么被折叠?



