我有功课,我必须创建一个C程序,从最小到最大排序5个数字.我知道如何使用函数和if语句(使用>=和<=)轻松编程.
然而,美中不足的是,我只允许使用printf和scanf,所以我必须要计算所有的>=和<=内部的printf.我不允许使用三元运算符.
我一直在努力.所以我试着只排序3个数字,我仍然无法通过排序最小的数字.它只是保持打印1.
// This printf is just trying to figure out the smallest number from 3 numbers provided but it keeps printing 1.
printf("The ascending order of the numbers are: %d ",
(
(num1 <= num2 && num1 <= num3) || // Checking if num1 is the smallest
(num2 <= num1 && num2 <= num3) || // Checking if num2 is …Run Code Online (Sandbox Code Playgroud)