利用C语言排序编译成功,但运行结果有问题是怎么回事?

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图 从键盘输入3个整数,按照从小到大的顺序排序后输出。

【问题描述】
从键盘输入3个整数,按照从小到大的顺序排序后输出。
【样例输入】3,12,5
【样例输出】
please enter three numbers:
3,5,12
*/
#include <stdio.h>
int main()
{
int a,b,c,t;
printf("please enter three numbers:");
scanf("%d,%d,%d",&a,&b,&c);
if(a>b)
t=a,a=b,b=t;
if(b>c)
t=b,b=c,c=t;
if(a>c)
t=a,a=c,c=t;
printf("%d,%d,%d",a,b,c);
return 0;
}

运行结果及报错内容

0,3,2031646

我想要达到的结果

正确排序

运行了下没问题啊,你是不是运行的之前的结果,没保存

img

你输入3个数的时候是不是每个数之间没有用逗号啊。如果输入3,12,5不会有问题。输入3 12 5是错误的

修改见注释,供参考:

#include <stdio.h>
int main()
{
    int a, b, c, t;
    printf("please enter three numbers:");
    scanf("%d%d%d", &a, &b, &c); //scanf("%d,%d,%d", &a, &b, &c);这里输入时三个数间用 ','间隔:3,12,5
    if (a > b)                     //改为用空格间隔。 
        t = a, a = b, b = t;
    if (a > c)               //修改这句的顺序
        t = a, a = c, c = t;
    if (b > c)              //修改这句的顺序
        t = b, b = c, c = t;
    printf("%d,%d,%d", a, b, c);
    return 0;
}