{"id":160458,"date":"2019-10-21T12:06:58","date_gmt":"2019-10-21T04:06:58","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160458"},"modified":"2019-10-07T18:09:37","modified_gmt":"2019-10-07T10:09:37","slug":"amount-pre-line","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/amount-pre-line.html","title":{"rendered":"\u7b97\u6cd5\u4e4b\u5e38\u89c1\u6392\u5e8f\u7b97\u6cd5-\u5192\u6ce1\u6392\u5e8f\u3001\u5f52\u5e76\u6392\u5e8f\u3001\u5feb\u901f\u6392\u5e8f"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5bf9\u4e8e\u7f16\u7a0b\u4e2d\u7433\u7405\u6ee1\u76ee\u7684\u7b97\u6cd5\uff0c\u672c\u4eba\u5411\u6765\u662f\u4e0d\u5584\u6b64\u9053\u4e5f\u4e0d\u7cbe\u4e8e\u6b64\u7684\uff0c\u800c\u8bf4\u8d77\u6392\u5e8f\u7b97\u6cd5\uff0c\u4e5f\u53ea\u662f\u4f1a\u5192\u6ce1\u6392\u5e8f\u3002\u8fd8\u8bb0\u5f97\u5f53\u521d\u521a\u505a\u5f00\u53d1\u5de5\u4f5c\u9762\u8bd5\u7b2c\u4e00\u5bb6\u516c\u53f8\u65f6\uff0c\u9762\u8bd5\u5b98\u4fbf\u8ba9\u624b\u5199\u5192\u6ce1\u6392\u5e8f\uff08\u5165\u804c\u4e4b\u540e\u624d\u77e5\u9053\uff0c\u8fd9\u9762\u8bd5\u5b98\u5c31\u662f\u4e00\u4e2a\u5192\u6ce1\u6392\u5e8f\"\u75c5\u6001\"\u7231\u597d\u8005\uff0c\u9022\u9762\u8bd5\u5fc5\u8003\u5192\u6ce1\u6392\u5e8f-__-\uff09\u3002\u540e\u6765\u770b\u5434\u519b\u7684\u4e00\u4e9b\u6587\u7ae0\uff0c\u63d0\u5230\u63d0\u9ad8\u6548\u7387\u7684\u5173\u952e\u5c31\u662f\u5c11\u505a\u4e8b\u60c5\u4e0d\u505a\u65e0\u7528\u529f\uff0c\u4fbf\u5bf9\u8fd9\u4e0d\u8d77\u773c\u7684\u6392\u5e8f\u7b97\u6cd5\u6709\u4e86\u5174\u8da3\u3002\u521a\u597d\u4eca\u5929\u5468\u672b\u6709\u95f2\uff0c\u9042\u7814\u7a76\u4e00\u4e8c\uff0c\u4e0e\u5404\u4f4d\u9053\u53cb\u5171\u4eab\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u5192\u6ce1\u6392\u5e8f\u65f6\u95f4\u4e4b\u6240\u4ee5\u6548\u7387\u4f4e\uff0c\u5c31\u662f\u56e0\u4e3a\u5c06\u6240\u6709\u6570\u90fd\u4e00\u89c6\u540c\u4ec1\u4e0d\u505a\u533a\u5206\u6328\u4e2a\u6bd4\u8f83\uff0c\u8fd9\u662f\u6700\u666e\u901a\u7684\u505a\u4e8b\u65b9\u6cd5\uff0c\u6240\u4ee5\u6548\u7387\u4e5f\u662f\u6700\u666e\u901a\u7684\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aN\u7684\u5e73\u65b9\uff1b\u800c\u5f52\u5e76\u6392\u5e8f\u6548\u7387\u9ad8\uff0c\u5219\u662f\u91c7\u7528\u4e86\u5206\u6cbb\u7684\u601d\u60f3\uff0c\u5c06\u4e00\u4e2a\u6574\u4f53\u5206\u6210\u591a\u4e2a\u5c0f\u4efd\uff0c\u6bcf\u4e2a\u5c0f\u4efd\u6392\u597d\u5e8f\u4e4b\u540e\u518d\u4e92\u76f8\u6bd4\u8f83\uff0c\u8fd9\u6837\u5c31\u6bd4\u5192\u6ce1\u5feb\u4e86\u4e0d\u5c11\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aNlogN\uff1b\u5feb\u901f\u6392\u5e8f\u7684\u5e73\u5747\u65f6\u95f4\u590d\u6742\u5ea6\u4e5f\u662fNlogN\uff0c\u4f46\u662f\u5b9e\u9645\u7684\u8017\u8d39\u65f6\u95f4\u4f1a\u6bd4\u5f52\u5e76\u6392\u5e8f\u5feb\u4e24\u4e09\u500d\uff08\u5f53\u7136\u5feb\u6392\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\u65f6\u95f4\u590d\u6742\u5ea6\u8fd8\u662fN\u7684\u5e73\u65b9\uff0c\u6bd4\u5f52\u5e76\u6392\u5e8f\u5927\uff09\uff0c\u5b83\u7684\u5e73\u5747\u6267\u884c\u65f6\u95f4\u80fd\u6bd4\u5f52\u5e76\u66f4\u5feb\u4e00\u4e9b\u662f\u56e0\u4e3a\u5b83\u6bcf\u6b21\u5206\u7ec4\u65f6\u4e0d\u662f\u968f\u673a\u5206\u7ec4\u800c\u662f\u76f8\u5bf9\u6709\u5e8f\u7684\u5206\u7ec4\uff0c\u5373\u5148\u4ece\u6570\u7ec4\u4e2d\u968f\u673a\u53d6\u4e00\u4e2a\u6570\u4f5c\u4e3a\u57fa\u6570\uff0c\u7136\u540e\u5c06\u6570\u636e\u79fb\u52a8\uff0c\u4f7f\u5f97\u57fa\u6570\u4e00\u8fb9\u7684\u6570\u90fd\u6bd4\u5b83\u5c0f\uff0c\u53e6\u4e00\u8fb9\u7684\u6570\u90fd\u6bd4\u5b83\u5927\uff0c\u518d\u5728\u4e24\u8fb9\u5404\u53d6\u4e00\u4e2a\u57fa\u6570\u8fdb\u884c\u76f8\u540c\u7684\u79fb\u52a8\u3001\u5206\u7ec4\u64cd\u4f5c\uff0c\u9012\u5f52\u4e0b\u53bb\uff0c\u8fd9\u6837\u6bcf\u4e2a\u7ec6\u5206\u7684\u5c0f\u7ec4\u90fd\u5728\u6574\u4f53\u7684\u5927\u6570\u7ec4\u4e2d\u6709\u4e2a\u4f4d\u7f6e\uff0c\u5408\u5e76\u65f6\u76f4\u63a5\u6309\u4ece\u5c0f\u5230\u5927\u5c06\u5404\u4e2a\u5206\u7ec4\u5408\u5e76\u8d77\u6765\u5373\u53ef\uff0c\u6240\u4ee5\u4e00\u822c\u60c5\u51b5\u4e0b\u4f1a\u6bd4\u5f52\u5e76\u5feb\u4e00\u4e9b\u3002<\/p>\n \u4e86\u89e3\u4e86\u601d\u60f3\u4e4b\u540e\uff0c\u518d\u7528\u4ee3\u7801\u5b9e\u73b0\u76f8\u5bf9\u5c31\u4f1a\u5bb9\u6613\u5f88\u591a\u3002\u6b64\u5904\u5c31\u518d\u501f\u7528\u4e00\u4e2a\u76f4\u89c2\u4e00\u70b9\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u5f52\u5e76\u4e0e\u5feb\u6392\u4e8c\u8005\u7684\u533a\u522b\u3002\u5047\u8bbe\u67091000\u4e2a\u5b66\u751f\uff0c\u60f3\u5bf9\u4ed6\u4eec\u7684\u6210\u7ee9\u8fdb\u884c\u6392\u5e8f\u3002\u65b9\u6cd51\u501f\u7528\u5f52\u5e76\u6392\u5e8f\u7684\u601d\u60f3\uff0c\u5177\u4f53\u8fd9\u6837\u505a\uff1a\u5c06\u8fd91000\u4e2a\u4eba\u5206\u621010\u7ec4\uff0c\u5c06\u6bcf\u7ec4\u7684100\u4eba\u8fdb\u884c\u6392\u5e8f\uff0c\u6392\u5b8c\u4e4b\u540e\u518d\u5728\u5404\u7ec4\u4e4b\u95f4\u4ece\u5c0f\u5230\u5927\u4f9d\u6b21\u8fdb\u884c\u6bd4\u8f83\uff0c\u6700\u540e\u5f97\u5230\u6574\u4e2a\u7684\u6210\u7ee9\u6392\u540d\u3002\u65b9\u6cd52\u501f\u7528\u5feb\u901f\u6392\u5e8f\u7684\u601d\u60f3\uff0c\u5177\u4f53\u9700\u8fd9\u6837\u505a\uff1a\u5c061000\u4e2a\u4eba\u4e5f\u662f\u5206\u621010\u7ec4\uff0c\u4f46\u662f\u662f\u6309\u5206\u6570\u6bb5\u5206\uff0c0-10\u5206\u7684\u653e\u5728\u4e00\u7ec4\uff0c10-20\u5206\u7684\u653e\u5728\u4e00\u7ec4\uff0c20-30\u5206\u7684\u653e\u5728\u4e00\u7ec4\uff0c\u4f9d\u6b21\u7c7b\u63a8\uff0c\u5206\u5b8c\u7ec4\u4e4b\u540e\u518d\u5728\u5404\u4e2a\u5c0f\u7ec4\u4e2d\u8fdb\u884c\u6392\u5e8f\uff0c\u800c\u5f53\u4f60\u5408\u5e76\u5404\u4e2a\u5c0f\u7ec4\u65f6\uff0c\u53ea\u9700\u5c06\u5176\u6309\u4ece\u5c0f\u5230\u5927\u7684\u987a\u5e8f\u76f4\u63a5\u5408\u5e76\u5c31\u884c\uff0c\u65e0\u9700\u8ddf\u65b9\u6cd51\u4e00\u6837\u5c06\u5404\u5c0f\u7ec4\u4e2d\u7684\u6570\u636e\u53d6\u51fa\u6765\u8ddf\u5176\u4ed6\u5c0f\u7ec4\u4e2d\u7684\u6570\u636e\u6328\u4e2a\u6bd4\u8f83\u3002\u770b\u5230\u8fd9\u91cc\uff0c\u60f3\u5fc5\u5404\u4f4d\u9053\u53cb\u5bf9\u5feb\u6392\u6bd4\u5f52\u5e76\u6392\u5e8f\u8fd8\u8981\u5feb\u4e00\u4e9b\u7684\u539f\u56e0\u5c31\u6709\u4e86\u89e3\u4e86\u3002<\/p>\n \u7b97\u6cd5\u53ef\u4ee5\u7406\u89e3\u6210\u505a\u4e8b\u7684\u6280\u5de7\u6216\u8005\u8bf4\u5957\u8def\uff0c\u6211\u4eec\u5bf9\u5176\u7684\u7406\u89e3\u53ef\u4ee5\u4e0d\u6b62\u4e8e\u7f16\u7a0b\uff0c\u5b8c\u5168\u53ef\u4ee5\u63a8\u5e7f\u51fa\u53bb\u3002\u6bd4\u5982\u5f52\u5e76\u7684\u5206\u6cbb\u6cd5\uff0c\u5c06\u4e00\u4e2a\u5927\u4e8b\u60c5\u62c6\u89e3\u6210\u591a\u4e2a\u5c0f\u4e8b\u4ef6\uff0c\u89e3\u51b3\u8d77\u6765\u5c31\u4f1a\u65b9\u4fbf\u5f88\u591a\u3002\u95f2\u8bdd\u626f\u4e86\u4e00\u5927\u5806\uff0c\u4e0b\u9762\u5c31\u5c06\u6211\u81ea\u5df1\u5199\u7684\u6392\u5e8f\u7ed9\u5927\u5bb6\u8d34\u51fa\u6765\uff0c\u9644\u5e26\u4e0a\u6ce8\u91ca\u8bb2\u89e3\uff0c\u5982\u679c\u6709\u4e4b\u524d\u4e0d\u4e86\u89e3\u7684\u9053\u53cb\uff0c\u76f8\u4fe1\u770b\u5b8c\u4e4b\u540e\u4fbf\u4f1a\u5ff5\u5934\u901a\u900f\uff0c\u539f\u5730\u98de\u5347 >_< \u3002\n\n\u6b63\u6587\n\n[erji]\u5f52\u5e76\u6392\u5e8f[\/erji]\n\n\n \r\n\/\/ \u5f52\u5e76\u6392\u5e8f\r\n public static void mergeSort (int[] arr) {\r\n \/\/ \u5efa\u4e00\u4e2a\u4e34\u65f6\u6570\u636e\u6765\u5b58\u653e\u6570\u636e\r\n int[] temp = new int[arr.length];\r\n mergeSort(arr, 0, arr.length - 1, temp);\r\n }\r\n\r\n private static void mergeSort(int[] arr, int left, int right, int[] temp) {\r\n if (left < right) { \/\/ \u5982\u679c\u8d77\u59cb\u4e0b\u6807\u8ddf\u7ed3\u675f\u4e0b\u6807\u5dee\u503c\u5c0f\u4e8e1\uff0c\u5219\u4e0d\u8fdb\u884c\u64cd\u4f5c\r\n int mid = (left + right) \/ 2;\r\n mergeSort(arr, left, mid, temp); \/\/ \u5206\u7ec4\uff0c\u5c06\u5de6\u8fb9\u5206\u4e3a\u4e00\u7ec4\uff0c\u9012\u5f52\u8c03\u7528\u8fdb\u884c\u6392\u5e8f\r\n mergeSort(arr, mid+1, right, temp); \/\/ \u5c06\u53f3\u8fb9\u5206\u4e3a\u4e00\u7ec4\r\n merge(arr, left, mid, right, temp); \/\/\u5c06\u5de6\u53f3\u5206\u7ec4\u5408\u5e76\r\n }\r\n }\r\n\r\n private static void merge(int[] arr, int left, int mid, int right, int[] temp) {\r\n int i = left; \/\/ \u5b9a\u4e49\u5de6\u6307\u9488\r\n int j = mid + 1; \/\/ \u5b9a\u4e49\u53f3\u6307\u9488\r\n int t = 0; \/\/ \u7ed9temp\u4e34\u65f6\u6570\u7ec4\u7528\u7684\u6307\u9488\r\n while (i <= mid && j <= right) { \/\/ \u8bbe\u7f6e\u5de6\u53f3\u6307\u9488\u7684\u79fb\u52a8\u8fb9\u754c\r\n if (arr[i] <= arr[j]) { \/\/ \u6b64\u5904\u662f\u5347\u5e8f\uff0c\u6545\u8c01\u5c0f\u8c01\u5148\u8d4b\u7ed9\u4e34\u65f6\u6570\u7ec4\r\n temp[t++] = arr[i++];\r\n } else {\r\n temp[t++] = arr[j++];\r\n }\r\n }\r\n while (i <= mid) { \/\/ \u5982\u679c\u5de6\u8fb9\u6709\u5269\u4f59\uff0c\u5219\u653e\u5728temp\u4e2d\r\n temp[t++] = arr[i++];\r\n }\r\n while (j <= right) { \/\/ \u5982\u679c\u53f3\u8fb9\u6709\u5269\u4f59\uff0c\u4f9d\u6b21\u653e\u5165temp\u4e2d\r\n temp[t++] = arr[j++];\r\n }\r\n t = 0;\r\n \/\/ \u6b64\u65f6temp\u4e2d\u5df2\u7ecf\u662farr\u6570\u7ec4\u4e2d\u4e0b\u6807\u4eceleft\u5230right\u4e4b\u95f4\u6392\u597d\u5e8f\u7684\u6570\u636e\u4e86\uff0c\u56e0\u4e3atemp\u6bcf\u6b21\u90fd\u662f\u4ece0\u5f00\u59cb\u8d4b\u503c\uff0c\u6240\u4ee5\u9700\u5c06\u6392\u597d\u5e8f\u7684\u6570\u653e\u56dearr\u7684\u5bf9\u5e94\u4f4d\u7f6e\r\n while (left <= right) {\r\n \/\/ \u5c06left\u5230right\u4e4b\u95f4\u6392\u597d\u5e8f\u7684\u6570\u636e\u653e\u56dearr\u4e2d\uff0c\u6b64\u65f6left\u5230right\u4e4b\u95f4\u7684\u6570\u5c31\u662f\u6700\u7ec8\u6392\u597d\u5e8f\u7684\u6570\r\n arr[left++] = temp[t++];\r\n }\r\n }\r\n<\/pre>\n |