从键盘上输入3个整数,按照升序排序,最后输出结果。
输入格式:
输入三个整数,中间用空格分隔。
输出格式:
输出三个整数,中间用英文逗号分隔,最后换行。
输入样例1:
1 3 2
输出样例1:
1,2,3
//PTA 7-1
//三个整数排序
//by: 千里马000
#include<stdio.h>
void sort(int *a, int *b, int *c);//排序函数
int main(void)
{
int a;
int b;
int c;
scanf("%d %d %d", &a, &b, &c);
sort(&a, &b, &c);
printf("%d,%d,%d\n", a, b, c);
return 0;
}
void sort(int *a, int *b, int *c)//排序函数
{
if (*a > *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
if (*b > *c)
{
int temp = *b;
*b = *c;
*c = temp;
}
if (*a > *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
}