{"id":264,"date":"2011-09-14T13:15:21","date_gmt":"2011-09-14T05:15:21","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=264"},"modified":"2020-06-06T13:17:03","modified_gmt":"2020-06-06T05:17:03","slug":"%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84_%e9%93%be%e8%a1%a8_%e5%a4%9a%e9%a1%b9%e5%bc%8f%e6%b1%82%e5%af%bc_c%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=264","title":{"rendered":"\u6570\u636e\u7ed3\u6784_\u94fe\u8868_\u591a\u9879\u5f0f\u6c42\u5bfc_C++\u5b9e\u73b0"},"content":{"rendered":"\n<p>head.h<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;string>\nusing namespace std;\n\nclass NODE\n{\npublic:\n\tNODE();\n\tint coef;\n\tint exp;\n\tNODE *next;\n};\n\nNODE::NODE()\n{\n\tcoef = exp = 0;\n\tnext = NULL;\n}\n\nclass DATA\n{\npublic:\n\tDATA();\n\tvoid GetPoly();\n\tvoid Derivation();\n\tvoid Print();\nprivate:\n\tNODE *head, *p, *pre;\n\tint coef, exp;\n};\n\nDATA::DATA()\n{\n\tpre = head = p = NULL;\n\tcoef = exp = 0;\n}\n\nvoid DATA::GetPoly()\n{\n\tcout &lt;&lt; \"GetPoly Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tcout &lt;&lt; \"Please Input polynomial :\" &lt;&lt; endl &lt;&lt; endl;\n\tbool first = true;\n\twhile (cin >> coef >> exp)\n\t{\n\t\tif (first)\n\t\t{\n\t\t\thead = new NODE;\n\t\t\thead->coef = coef;\n\t\t\thead->exp = exp;\n\t\t\tp = head;\n\t\t\tfirst = !first;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tp->next = new NODE;\n\t\t\tp = p->next;\n\t\t\tp->coef = coef;\n\t\t\tp->exp = exp;\n\t\t}\n\t}\n\tcin.clear();\n}\n\nvoid DATA::Derivation()\n{\n\tcout &lt;&lt; \"Derivation Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tif (head == NULL)\n\t{\n\t\tcout &lt;&lt; \"No Data !\" &lt;&lt; endl &lt;&lt; endl;\n\t\treturn;\n\t}\n\telse\n\t{\n\t\tpre = p = head;\n\t\twhile (p != NULL)\n\t\t{\n\t\t\tif (p->exp == 0)\n\t\t\t{\n\t\t\t\tif (p == head)\n\t\t\t\t{\n\t\t\t\t\thead = head->next;\n\t\t\t\t\tdelete p;\n\t\t\t\t\tpre = p = head;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tpre->next = p->next;\n\t\t\t\t\tdelete p;\n\t\t\t\t\tp = pre->next;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp->coef *= p->exp;\n\t\t\t\tp->exp--;\n\t\t\t\tpre = p;\n\t\t\t\tp = p->next;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid DATA::Print()\n{\n\tcout &lt;&lt; \"Print Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tif (head == NULL)\n\t{\n\t\tcout &lt;&lt; \"No Data !\" &lt;&lt; endl &lt;&lt; endl;\n\t\treturn;\n\t}\n\tp = head;\n\tcout &lt;&lt; p->coef;\n\tif (p->exp != 0)\n\t\tcout &lt;&lt; \"x^\" &lt;&lt; p->exp;\n\tp = p->next;\n\twhile (p != NULL)\n\t{\n\t\tcout &lt;&lt; \"+\" &lt;&lt; p->coef;\n\t\tif (p->exp != 0)\n\t\t\tcout &lt;&lt; \"x^\" &lt;&lt; p->exp;\n\t\tp = p->next;\n\t}\n\tcout &lt;&lt; endl &lt;&lt; endl &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\"head.h\"\n \nint main()\n{\n\tDATA data;\n\tdata.GetPoly();\n\tdata.Print();\n\tdata.Derivation();\n\tdata.Print();\n\tsystem(\"pause\");\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>head.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-264","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\/264","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=264"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}