写了一个输入数目字排序,咋就不对呢老。

写了一个输入数字排序,咋就不对呢老。。
#include <stdio.h>
main()
{
int str[50];
int i,j,temp;
printf("enter 4 numbers:\n");
for(i = 0;i <= 3;i++)
scanf("%d",&str[i]);
for(i = 0;i < 3;i++)
{
for(j = i+1;j < 4;j++)
{
if(str[i] > str[j])
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
for(i = 0;i < 4;i++)
printf("the numbers is:%d\n",str[i]);
}

------解决方案--------------------
if 语句要加上大括号把交换语句括起来
if(str[i] > str[j]) {
                temp = str[i];
                str[i] = str[j];
                str[j] = temp;
}
------解决方案--------------------
不括起来的话相当于噢
        for(j = i+1;j < 4;j++)
        {
            str[i] = str[j];
            str[j] = temp;
            
            if(str[i] > str[j])
                temp = str[i];

        }