Created
December 16, 2012 14:48
-
-
Save yulanggong/4308003 to your computer and use it in GitHub Desktop.
三目运算该怎么写?
This file contains 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
//第一种 | |
num < 2 | |
? num < 1 | |
? 0 | |
: 1 | |
: num < 3 | |
? 2 | |
: 3 | |
//第二种 | |
num < 2 ? | |
num < 1 ? | |
0 : | |
1 : | |
num < 3 ? | |
2 : | |
3 ; | |
//第三种 | |
num < 1 ? 0 : | |
num < 2 ? 1 : | |
num < 3 ? 2 : | |
3 ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment