Created
November 14, 2012 10:06
-
-
Save freetstar/4071322 to your computer and use it in GitHub Desktop.
a,b,c三个整数依次从大到小输出结果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int max(int n,int m) | |
{ | |
return m>=n?m:n; | |
} | |
int min(int n,int m) | |
{ | |
return m>=n?n:m; | |
} | |
int main(int argc,char *argv[]) | |
{ | |
int a = 3 ,b=4,c=5; | |
int maxNum,minNum,midNum; | |
maxNum = max(a,b) >= max(b,c)? max(a,b):max(b,c); | |
minNum = min(a,b) >= min(b,c)? min(b,c):min(a,b); | |
midNum = minNum==a?(maxNum == b ? a:b):c; | |
printf("max %d,min %d,mid %d\n",maxNum,minNum,midNum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment