{"id":38457,"date":"2024-11-26T11:13:39","date_gmt":"2024-11-26T03:13:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38457\/"},"modified":"2024-11-26T11:13:39","modified_gmt":"2024-11-26T03:13:39","slug":"java%e6%80%8e%e4%b9%88%e8%be%93%e5%85%a5%e4%ba%8c%e7%bb%b4%e5%ad%97%e7%ac%a6%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38457\/","title":{"rendered":"java\u600e\u4e48\u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u4f7f\u7528 java \u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u76f4\u63a5\u521b\u5efa\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff1achar[][] arr = {{&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;}, {&#8216;d&#8217;, &#8216;e&#8217;, &#8216;f&#8217;}, {&#8216;g&#8217;, &#8216;h&#8217;, &#8216;i&#8217;}};\u4f7f\u7528\u5faa\u73af\u521b\u5efa\u548c\u8f93\u5165\u4e8c\u7ef4\u6570\u7ec4\uff1a(1) \u83b7\u53d6\u884c\u6570\u548c\u5217\u6570(2) \u521b\u5efa\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4(3) \u8f93\u5165\u5143\u7d20(4) \u5c55\u793a\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/15\/2024111502033622379.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Java \u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u521b\u5efa\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<pre>char[][] arr = {{'a', 'b', 'c'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}};<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4f7f\u7528\u5faa\u73af\u521b\u5efa\u548c\u8f93\u5165\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/p>\n<pre>import java.util.Scanner;\n\npublic class Input2DCharArray {\n\n    public static void main(String[] args) {\n        Scanner scanner = new Scanner(System.in);\n        int rows, cols;\n\n        \/\/ \u83b7\u53d6\u884c\u6570\u548c\u5217\u6570\n        System.out.print(\"\u8bf7\u8f93\u5165\u884c\u6570\uff1a\");\n        rows = scanner.nextInt();\n        System.out.print(\"\u8bf7\u8f93\u5165\u5217\u6570\uff1a\");\n        cols = scanner.nextInt();\n\n        \/\/ \u521b\u5efa\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\n        char[][] arr = new char[rows][cols];\n\n        \/\/ \u8f93\u5165\u5143\u7d20\n        for (int i = 0; i &lt; rows; i++) {\n            for (int j = 0; j &lt; cols; j++) {\n                System.out.print(\"\u8bf7\u8f93\u5165\u7b2c \" + (i + 1) + \" \u884c\u7b2c \" + (j + 1) + \" \u5217\u7684\u5b57\u7b26\uff1a\");\n                arr[i][j] = scanner.next().charAt(0);\n            }\n        }\n\n        \/\/ \u5c55\u793a\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\n        for (char[] row : arr) {\n            for (char c : row) {\n                System.out.print(c + \" \");\n            }\n            System.out.println();\n        }\n    }\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 java \u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff1a\u76f4\u63a5\u521b\u5efa\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4\uff1achar[][] arr = {{&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;}, {&#8216;d&#8217;, &#8216;e&#8217;, &#8216;f&#8217;}, {&#8216;g&#8217;, &#8216;h&#8217;, &#8216;i&#8217;}};\u4f7f\u7528\u5faa\u73af\u521b\u5efa\u548c\u8f93\u5165\u4e8c\u7ef4\u6570\u7ec4\uff1a(1) \u83b7\u53d6\u884c\u6570\u548c\u5217\u6570(2) \u521b\u5efa\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4(3) \u8f93\u5165\u5143\u7d20(4) \u5c55\u793a\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4 \u5982\u4f55\u4f7f\u7528 Java \u8f93\u5165\u4e8c\u7ef4\u5b57\u7b26\u6570\u7ec4 \u76f4\u63a5\u521b\u5efa\u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4 char[][] arr = {{&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;}, {&#8216;d&#8217;, &#8216;e&#8217;, &#8216;f&#8217;}, {&#8216;g&#8217;, &#8216;h&#8217;, &#8216;i&#8217;}}; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5faa\u73af\u521b\u5efa\u548c\u8f93\u5165\u4e8c\u7ef4\u6570\u7ec4 import java.util.Scanner; public class Input2DCharArray { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int rows, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-38457","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=38457"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38457\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}