您的位置:首页 > 编程语言 > Java开发

Code Hunt Sector 04 Conditionals - Java

2016-06-04 00:00 274 查看
摘要: Code Hunt Sector 04 Conditionals - Java

微软编码游戏 https://www.codehunt.com

Code Hunt 04.01

[code=language-java]public class Program {
public static Boolean Puzzle(Boolean x, Boolean y) {
return x || y;
}
}


Code Hunt 04.02

[code=language-java]public class Program {
public static Boolean Puzzle(Boolean x, Boolean y) {
return x && y;
}
}


Code Hunt 04.03

[code=language-java]public class Program {
public static Boolean Puzzle(int x) {
return x < 50;
}
}


Code Hunt 04.04

[code=language-java]public class Program {
public static Boolean Puzzle(int x, int y) {
return x < y;
}
}


Code Hunt 04.05

[code=language-java]public class Program {
public static int Puzzle(int i) {
return (i >> 31) | (-i >>> 31);
}
}


Code Hunt 04.06

[code=language-java]public class Program {
public static Boolean Puzzle(int i, int j) {
return false;//令人无语
}
}


Code Hunt 04.07

[code=language-java]public class Program {
public static int Puzzle(int i) {
return i < 100 ? 2 : 3;
}
}


Code Hunt 04.08

[code=language-java]public class Program {
public static String Puzzle(int i) {
return i % 2 == 0 ? "even" : "odd";
}
}


Code Hunt 04.09

[code=language-java]public class Program {
public static String Puzzle(int i) {
return i % 5 == 0 ? "multiple of 5" : "not a multiple of 5";
}
}


Code Hunt 04.10

[code=language-java]public class Program {
public static String Puzzle(int i, int x) {
return i % x == 0 ? ("multiple of " + x) : ("not a multiple of " + x);
}
}


Code Hunt 04.11

[code=language-java]public class Program {
public static String Puzzle(int i, int j, int k) {
return i == 2 * j && j == 2 * k ? "yes!" : "no";
}
}


Code Hunt 04.12

[code=language-java]public class Program {
public static int Puzzle(int i) {
return i > 14 ? 21 : (i - 1) / 7 * 7;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  codehunt