主题:输出从小到大的数问题
如下面的程序,我在TC下输入1,2,3得到的结果是:1,2,3,879
在VC++里的结果是1,2,3,-858993460
应该返回的是1,2,3,3才对啊,如果输入的是2,1,3或者3,1,2或者3,2,1都正常输出,为什么输入1,2,3的时候她t输出的就不一样了呢??
#include <stdio.h>
int main()
{
int a,b,c,t;
scanf("%d,%d,%d",&a,&b,&c);
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,%d\n",a,b,c,t);
}
在VC++里的结果是1,2,3,-858993460
应该返回的是1,2,3,3才对啊,如果输入的是2,1,3或者3,1,2或者3,2,1都正常输出,为什么输入1,2,3的时候她t输出的就不一样了呢??
#include <stdio.h>
int main()
{
int a,b,c,t;
scanf("%d,%d,%d",&a,&b,&c);
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,%d\n",a,b,c,t);
}