輸出最大值:
#include
void main()
{
int a,b,c,Max;
scanf("%d %d %d",&a,&b,&c);
if (a
Max = b;
else
Max = a;
if (Max
printf("%d",c);
printf("%d",Max);
}
輸入三個數(空格隔開),先比較前兩個數大小,將較大的數賦值給Max,再比較Max與第三個數大小,輸出較大的數
按降序輸出:
int a,b,c,max_ab,min_ab;
max_ab = b;
min_ab = a;
max_ab = a;
min_ab = b;
if (max_ab
printf("%d %d %d",c,max_ab,min_ab);
else if (max_ab > c && c >min_ab)
printf("%d %d %d",max_ab,c,min_ab);
else if (max_ab > c && c
printf("%d %d %d",max_ab,min_ab,c);
輸入三個數,判斷前兩個數,將大的數賦值給max_ab,小的數賦值給min_ab,再將max_ab與c作比較。若c大於等於max_ab,則輸出c,max_ab,min_ab.若c小於max_ab且大於min_ab,則輸出max_ab,c,min_ab.若c小於min_ab,則輸出max_ab,min_ab,c
輸出最大值:
#include
void main()
{
int a,b,c,Max;
scanf("%d %d %d",&a,&b,&c);
if (a
Max = b;
else
Max = a;
if (Max
printf("%d",c);
else
printf("%d",Max);
}
輸入三個數(空格隔開),先比較前兩個數大小,將較大的數賦值給Max,再比較Max與第三個數大小,輸出較大的數
按降序輸出:
#include
void main()
{
int a,b,c,max_ab,min_ab;
scanf("%d %d %d",&a,&b,&c);
if (a
{
max_ab = b;
min_ab = a;
}
else
{
max_ab = a;
min_ab = b;
}
if (max_ab
printf("%d %d %d",c,max_ab,min_ab);
else if (max_ab > c && c >min_ab)
printf("%d %d %d",max_ab,c,min_ab);
else if (max_ab > c && c
printf("%d %d %d",max_ab,min_ab,c);
}
輸入三個數,判斷前兩個數,將大的數賦值給max_ab,小的數賦值給min_ab,再將max_ab與c作比較。若c大於等於max_ab,則輸出c,max_ab,min_ab.若c小於max_ab且大於min_ab,則輸出max_ab,c,min_ab.若c小於min_ab,則輸出max_ab,min_ab,c