{"id":319,"date":"2011-10-18T14:15:27","date_gmt":"2011-10-18T06:15:27","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=319"},"modified":"2020-06-06T14:16:36","modified_gmt":"2020-06-06T06:16:36","slug":"%e6%95%b0%e7%bb%84%e4%b8%8e%e5%b9%bf%e4%b9%89%e8%a1%a8_%e7%a8%80%e7%96%8f%e7%9f%a9%e9%98%b5%e7%9a%84%e5%8e%8b%e7%bc%a9%e5%ad%98%e5%82%a8_%e4%b8%89%e5%85%83%e7%bb%84%e5%81%9a%e5%ad%98%e5%82%a8%e7%bb%93","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=319","title":{"rendered":"\u6570\u7ec4\u4e0e\u5e7f\u4e49\u8868_\u7a00\u758f\u77e9\u9635\u7684\u538b\u7f29\u5b58\u50a8_\u4e09\u5143\u7ec4\u505a\u5b58\u50a8\u7ed3\u6784_\u77e9\u9635\u8f6c\u7f6e"},"content":{"rendered":"\n<p>Matrix.h<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\nusing namespace std;\n\n#define MAX_MATRIXSIZE 20\n#define ElemType int\n\nclass Triple \/\/\u4e09\u5143\u7ec4\u7c7b\n{\npublic:\n\tint i, j; \/\/\u884c\u5217\u53f7\n\tElemType e; \/\/\u5143\u7d20\u503c\n};\n\nclass TSMatrix \/\/\u77e9\u9635\u7c7b\n{\npublic:\n\tTSMatrix();\n\tTriple matrix&#91;MAX_MATRIXSIZE]; \/\/\u4e09\u5143\u7ec4\u96c6\u5408 \n\tint mu, nu, tu; \/\/\u884c\u6570\uff0c\u5217\u6570\uff0c\u975e\u96f6\u5143\u4e2a\u6570\n};\n\nTSMatrix::TSMatrix()\n{\n\tmu = nu = tu = 0;\n}\n\nclass Matrix \/\/\u77e9\u9635\u7c7b\u5c01\u88c5\u4e86\u6709\u5173\u77e9\u9635\u7684\u5404\u79cd\u64cd\u4f5c\n{\npublic:\n\tvoid GetMatrix(); \/\/\u5f97\u5230\u77e9\u9635\u7684\u4e09\u5143\u7ec4\n\tvoid TransposeSMatrix(); \/\/\u77e9\u9635\u8f6c\u7f6e\n\tvoid PrintMatrix(); \/\/\u6253\u5370\u77e9\u9635\nprivate:\n\tvoid PrintMatrix(Triple&#91;]); \/\/\u91cd\u8f7d\u51fd\u6570\u7528\u4e8e\u6253\u5370\u8f6c\u7f6e\u77e9\u9635\n\tvoid GetCpot(int&#91;]); \/\/\u6c42\u8f6c\u7f6e\u77e9\u9635\u65f6\u7528\u4e8e\u6c42\u5f97\u8f85\u52a9\u6570\u7ec4Cpot\u7684\u503c\n\tTSMatrix m; \/\/\u5b9e\u4f8b\u5316\u4e00\u4e2a\u77e9\u9635\u7c7b\u7684\u5bf9\u8c61\n};\n\nvoid Matrix::GetMatrix() \/\/\u5f97\u5230\u77e9\u9635\u7684\u4e09\u5143\u7ec4\n{\n\tcout &lt;&lt; \"Please Input The Size Of The Matrix(m*n)\" &lt;&lt; endl;\n\tcin >> m.mu >> m.nu;\n\tcout &lt;&lt; \"Please Input Matrix With Increasing Order Of RowNumber\" &lt;&lt; endl\n\t\t\t&lt;&lt; \"rownum columnnum element\" &lt;&lt; endl &lt;&lt; endl;\n\tint i, j;\n\tElemType e;\n\twhile (cin >> i >> j >> e)\n\t{\n\t\tm.matrix&#91;m.tu].i = i;\n\t\tm.matrix&#91;m.tu].j = j;\n\t\tm.matrix&#91;m.tu].e = e;\n\t\tm.tu++;\n\t}\n\tcin.clear();\n}\n\nvoid Matrix::GetCpot(int Cpot&#91;]) \/\/\u6c42\u8f6c\u7f6e\u77e9\u9635\u65f6\u7528\u4e8e\u6c42\u5f97\u8f85\u52a9\u6570\u7ec4Cpot\u7684\u503c\n{\n\tint num&#91;MAX_MATRIXSIZE];\n\tmemset(num, 0, sizeof(num));\n\tfor (int i = 0; i &lt; m.tu; i++)\n\t\tnum&#91;m.matrix&#91;i].j]++;\n\tCpot&#91;1] = 1;\n\tfor (int i = 2; i &lt; m.nu; i++)\n\t\tCpot&#91;i] = Cpot&#91;i - 1] + num&#91;i - 1];\n}\n\nvoid Matrix::TransposeSMatrix() \/\/\u77e9\u9635\u8f6c\u7f6e\n{\n\tint Cpot&#91;MAX_MATRIXSIZE];\n\tGetCpot(Cpot);\n\tTriple temp&#91;MAX_MATRIXSIZE];\n\tfor (int i = 0; i &lt; m.tu; i++)\n\t{\n\t\ttemp&#91;Cpot&#91;m.matrix&#91;i].j] - 1].i = m.matrix&#91;i].j;\n\t\ttemp&#91;Cpot&#91;m.matrix&#91;i].j] - 1].j = m.matrix&#91;i].i;\n\t\ttemp&#91;Cpot&#91;m.matrix&#91;i].j] - 1].e = m.matrix&#91;i].e;\n\t\tCpot&#91;m.matrix&#91;i].j]++;\n\t}\n\tcout &lt;&lt; endl;\n\tPrintMatrix(temp);\n}\n\nvoid Matrix::PrintMatrix() \/\/\u6253\u5370\u77e9\u9635\n{\n\tfor (int i = 0; i &lt; m.tu; i++)\n\t\tcout &lt;&lt; m.matrix&#91;i].i &lt;&lt; \" \" &lt;&lt; m.matrix&#91;i].j &lt;&lt; \" \" &lt;&lt; m.matrix&#91;i].e\n\t\t\t\t&lt;&lt; endl;\n}\n\nvoid Matrix::PrintMatrix(Triple t&#91;]) \/\/\u91cd\u8f7d\u51fd\u6570\u7528\u4e8e\u6253\u5370\u8f6c\u7f6e\u77e9\u9635\n{\n\tfor (int i = 0; i &lt; m.tu; i++)\n\t\tcout &lt;&lt; t&#91;i].i &lt;&lt; \" \" &lt;&lt; t&#91;i].j &lt;&lt; \" \" &lt;&lt; t&#91;i].e &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<p>main.cpp<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include\"Matrix.h\"\n \nint main()\n{\n\tMatrix m;\n\tm.GetMatrix();\n\tm.PrintMatrix();\n\tm.TransposeSMatrix();\n\tsystem(\"pause\");\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Matrix.h main.cpp<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-06-02-"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}