{"id":634,"date":"2020-03-04T22:38:06","date_gmt":"2020-03-04T14:38:06","guid":{"rendered":"http:\/\/kylelv.com\/?p=634"},"modified":"2020-03-10T00:01:54","modified_gmt":"2020-03-09T16:01:54","slug":"%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%ef%bc%8c%e8%bf%90%e7%ae%97%e7%ac%a6%e9%87%8d%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=634","title":{"rendered":"\u81ea\u5b9a\u4e49\u4e8c\u7ef4\u6570\u7ec4\uff0c\u8fd0\u7b97\u7b26\u91cd\u8f7d"},"content":{"rendered":"\n<h2 class=\"has-text-align-center wp-block-heading\">\u7b2c\u56db\u5468\u7a0b\u5e8f\u586b\u7a7a\u98983<\/h2>\n\n\n\n<p class=\"has-text-align-center\">\u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u63cf\u8ff0<\/p>\n\n\n\n<p>\u5199\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7c7b Array2,\u4f7f\u5f97\u4e0b\u9762\u7a0b\u5e8f\u7684\u8f93\u51fa\u7ed3\u679c\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0,1,2,3,\n4,5,6,7,\n8,9,10,11,\nnext\n0,1,2,3,\n4,5,6,7,\n8,9,10,11,<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream>\n#include &lt;cstring>\nusing namespace std;\n\nclass Array2 {\n\tint** p;\n\tint n,m;\n\tpublic:\n\tArray2(int a=0,int b=0){\n\t\tn=a;m=b;\n\t\tif(!a||!b) p=NULL;\n\t\telse {\n\t\t\tp=new int* [a];\n\t\t\tfor(int i=0;i&lt;a;i++){\n\t\t\t\tp[i]=new int[b];\n\t\t\t\tmemset(p[i],0,b*sizeof(int));\n\t\t\t}\n\t\t}\n\t}\n\t~Array2(){\n\t\tfor(int i=0;i&lt;n;i++)\n\t\t\tdelete []p[i];\n\t\tdelete []p;\n\t}\n\tArray2 &amp; operator =(const Array2 &amp;x){\n\t\tif(&amp;x==this) return *this;\n\t\tif(p!=NULL){\n\t\t\tfor(int i=0;i&lt;n;i++)\n\t\t\t\tdelete []p[i];\n\t\t\tdelete []p;\n\t\t}\n\t\tn=x.n;m=x.m;\n\t\tp=new int* [x.n];\n\t\tfor(int i=0;i&lt;x.n;i++){\n\t\t\tp[i]=new int [x.m];\n\t\t\tmemcpy(p[i],x.p[i],x.m*sizeof(int));\n\t\t}\n\t\treturn *this;\n\t}\n\tint operator ()(int a,int b){return p[a][b];}\n\tint* operator [](int x){return p[x];}\n\/\/ \u5728\u6b64\u5904\u8865\u5145\u4f60\u7684\u4ee3\u7801\n};\n\nint main() {\n    Array2 a(3,4);\n    int i,j;\n    for(  i = 0;i &lt; 3; ++i )\n        for(  j = 0; j &lt; 4; j ++ )\n            a[i][j] = i * 4 + j;\n    for(  i = 0;i &lt; 3; ++i ) {\n        for(  j = 0; j &lt; 4; j ++ ) {\n            cout &lt;&lt; a(i,j) &lt;&lt; \",\";\n        }\n        cout &lt;&lt; endl;\n    }\n    cout &lt;&lt; \"next\" &lt;&lt; endl;\n    Array2 b;     b = a;\n    for(  i = 0;i &lt; 3; ++i ) {\n        for(  j = 0; j &lt; 4; j ++ ) {\n            cout &lt;&lt; b[i][j] &lt;&lt; \",\";\n        }\n        cout &lt;&lt; endl;\n    }\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u56db\u5468\u7a0b\u5e8f\u586b\u7a7a\u98983 \u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB \u63cf\u8ff0 \u5199\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7c7b Array [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-70"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=634"}],"version-history":[{"count":3,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":663,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/634\/revisions\/663"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}