Code Hunt Sector 03 Loops 2 - Java
2016-06-04 00:00
369 查看
摘要: Code Hunt Sector 03 Loops 2 - Java
微软编码游戏 https://www.codehunt.com
Code Hunt 03.01
Code Hunt 03.02
Code Hunt 03.03
Code Hunt 03.04
Code Hunt 03.05
Code Hunt 03.06
Code Hunt 03.07
Code Hunt 03.08
微软编码游戏 https://www.codehunt.com
Code Hunt 03.01
[code=language-java]public class Program { public static int Puzzle(int number, int power) { return power == 0 ? 1 : number * Puzzle(number, power - 1); } }
Code Hunt 03.02
[code=language-java]public class Program { public static int Puzzle(int i) { int result = 1; for (int j = 2; j <= i; j++) { result = result * j; } return result; } }
Code Hunt 03.03
[code=language-java]public class Program { public static int Puzzle(int lowerBound, int upperBound) { int result = 1; for (int i = lowerBound; i <= upperBound; i++) { result = result * i; } return result; } }
Code Hunt 03.04
[code=language-java]public class Program { public static int Puzzle(int n) { int result = 0; for (int i = 2; i < n; i += 2) { result = result + i; } return result; } }
Code Hunt 03.05
[code=language-java]public class Program { public static int Puzzle(int upperBound) { return upperBound == 1 ? 1 : (upperBound * (1 + upperBound) / 2) + Puzzle(upperBound - 1); } }
Code Hunt 03.06
[code=language-java]public class Program { public static String Puzzle(String word) { String s = word.replaceAll(".", "_ "); return s.substring(0, s.length() - 1); } }
Code Hunt 03.07
[code=language-java]public class Program { public static String Puzzle(String s) { char[] c = s.toCharArray(); for (int i = 0; i < c.length; i++) { c[i] = (char) ((((int) c[i] + 5) - 97) % 26 + 97); } return new String(c); } }
Code Hunt 03.08
[code=language-java]public class Program { public static int Puzzle(int x) { return (x + "").length(); } }
相关文章推荐
- 【CodeHunt】噢,听说今年的CH又开始了
- Code Hunt Sector 04 Conditionals - Java
- Code Hunt Sector 05 Conditionals 2 - Java
- Code Hunt Sector 06 Strings - Java
- Code Hunt Sector 07 Strings 2 - Java
- Code Hunt Sector 08 Nested Loops - Java
- Code Hunt Sector 09 1D Arrays - Java
- Code Hunt Sector 14 Puzzles - Java
- Code Hunt Sector 13 Cyphers - Java
- Code Hunt Sector 12 Search Sort - Java
- Code Hunt Sector 11 Arrays 2 - Java
- Code Hunt Sector 10 Jagged Arrays - Java
- Code Hunt Sector 02 Loops - Java
- Code Hunt Sector 01 Arithmetic - Java
- Code Hunt Sector 00 Training - Java