摘要: 按长度为8拆分每个字符串后输出到新的字符串数组,长度不是8整数倍的字符串请在后面补数字0,空字符串不处理 public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = 0; 阅读全文
posted @ 2020-07-01 23:13 冬马党 阅读(509) 评论(0) 推荐(0)
摘要: 空间复杂度为O(3),时间复杂度为O(n);平均值保留一位小数,如果没有正数则平均值输出0.0 /** * 计负均正,空间复杂度为O(3),时间复杂度为O(n) **/private static void calc(int[] arr) { int negCount = 0; int posCou 阅读全文
posted @ 2020-07-01 22:16 冬马党 阅读(218) 评论(0) 推荐(0)
摘要: /** * 将一个字符串进行反转 **/private static String reverse(String str) { char[] chars = new char[str.length()]; int len = str.length() - 1; for (int i = 0; i < 阅读全文
posted @ 2020-07-01 21:57 冬马党 阅读(311) 评论(0) 推荐(0)
摘要: /** * 求一个数的立方根,利用二分法,时间复杂度在logn **/ private static double getCubeRoot(double input){ double min = 0; double max = input; double mid = 0; while ((max - 阅读全文
posted @ 2020-07-01 21:45 冬马党 阅读(353) 评论(0) 推荐(0)
摘要: private static int minCommonMultiple(int m,int n){ return n * m / maxCommonDivisor(m,n); } /** * 求最大公约数 **/ private static int maxCommonDivisor(int m, 阅读全文
posted @ 2020-07-01 21:30 冬马党 阅读(108) 评论(0) 推荐(0)