inta,b,c;
intmin,max,between;
min=(a<b)?((a<c)?a:c):((b<c)?b:c);
max=(a>b)?((a>c)?a:c):((b>c)?b:c);
示例如下:
#include<stdio.h>
voidmain()
{
printf("輸入三個整數:");
scanf("%d%d%d",&a,&b,&c);
between=(a>b)?((a>c)?((b>c)?b:c):a):((b>c)?((c>a)?c:a):b);
printf("從小到大排列為:%d%d%d",min,between,max);
}
inta,b,c;
intmin,max,between;
min=(a<b)?((a<c)?a:c):((b<c)?b:c);
max=(a>b)?((a>c)?a:c):((b>c)?b:c);
示例如下:
#include<stdio.h>
voidmain()
{
inta,b,c;
intmin,max,between;
printf("輸入三個整數:");
scanf("%d%d%d",&a,&b,&c);
min=(a<b)?((a<c)?a:c):((b<c)?b:c);
max=(a>b)?((a>c)?a:c):((b>c)?b:c);
between=(a>b)?((a>c)?((b>c)?b:c):a):((b>c)?((c>a)?c:a):b);
printf("從小到大排列為:%d%d%d",min,between,max);
}