{"id":355,"date":"2006-06-02T16:06:31","date_gmt":"2006-06-02T08:06:31","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/355.aspx"},"modified":"2006-06-02T20:06:45","modified_gmt":"2006-06-02T12:06:45","slug":"24%e7%82%b9%e7%9a%84%e4%b8%89%e7%a7%8d%e7%ae%97%e6%b3%95%e6%80%9d%e8%b7%af%e5%8f%8a%e4%bb%a3%e7%a0%81(3)","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/355","title":{"rendered":"24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(3)"},"content":{"rendered":"<p>\u5148\u516c\u5e03\u4e00\u4e0b\u7b2c\u4e00\u7bc7\u6587\u7ae0\u4e2d\u63d0\u51fa\u7684\u95ee\u9898\u7684\u7b54\u6848\uff1a<br \/>1,5,5,5\uff1a(5-1\/5)*5=24<br \/>3,3,8,8\uff1a8\/(3-8\/3)=24<\/p>\n<p>\u6b64\u6587\u6240\u8d34\u4ee3\u7801\u5747\u4e3a\u9762\u5411\u8fc7\u7a0b\u7684C(++)\u4ee3\u7801\uff0c\u5728VC6\u4e0b\u7f16\u8bd1\u901a\u8fc7\u3002<\/p>\n<p><b>\u7b2c\u4e8c\u79cd\u601d\u8def\uff1a<\/b><\/p>\n<p>\u8fd8\u662f\u5c3d\u91cf\u907f\u514d\u5904\u7406\u62ec\u53f7\uff0c\u5b9e\u5728\u662f\u5f88\u9ebb\u70e6\u3002\u6709\u4e00\u79cd\u6ca1\u6709\u62ec\u53f7\u7684\u8868\u8fbe\u5f0f\u2014\u2014\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\uff08\u540e\u7f00\u8868\u8fbe\u5f0f\uff09\uff0c\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\u4e25\u683c\u5730\u6309\u7167\u4ece\u5de6\u81f3\u53f3\u7684\u987a\u5e8f\u6267\u884c\u3002\u56e0\u6b64\uff0c\u53ea\u9700\u628a\u6240\u6709\u7684\u6570\u5b57\u7684\u6392\u5217\u7ec4\u5408\u4e0e\u6240\u6709\u7684\u7b26\u53f7\u7684\u6392\u5217\u7ec4\u5408\u518d\u8fdb\u884c\u6392\u5217\u7ec4\u5408\u5373\u53ef\u904d\u5386\u6240\u6709\u53ef\u80fd\u7684\u8868\u8fbe\u5f0f\u3002\u5728\u8f93\u51fa\u7ed3\u679c\u65f6\uff0c\u53ea\u9700\u628a\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\u6309\u7167\u89c4\u5219\u8fd8\u539f\u6210\u6b63\u5e38\u7684\u8868\u8fbe\u5f0f\u5373\u53ef\u3002<\/p>\n<p>\u8bf4\u660e\uff1a&#8217;-&#8216;\u548c&#8217;\/&#8217;\u6709\u4e24\u79cd\u60c5\u51b5\uff0c&#8217;a-b&#8217;\u7528&#8217;a-b&#8217;\u8868\u793a,&#8217;b-a&#8217;\u7528&#8217;a|b&#8217;\u8868\u793a\uff0c&#8217;a\/b&#8217;\u7528&#8217;a\/b&#8217;\u8868\u793a\uff0c&#8217;b\/a&#8217;\u7528&#8217;a\\b&#8217;\u8868\u793a\uff0c&#8217;\\&#8217;\u662f\u8f6c\u4e49\u5b57\u7b26\uff0c\u8981\u7528&#8217;\\\\&#8217;\u8868\u793a\u3002<\/p>\n<p>\u7a0b\u5e8f\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<blockquote>\n<p>\/********************************\/<br \/>\/*\tfdream.net\t\t*\/<br \/>\/*\t Author:Fdream\t\t*\/<br \/>\/*    \u5f15\u7528\u6b64\u7b97\u6cd5\u8bf7\u4fdd\u7559\u6b64\u4fe1\u606f    *\/<br \/>\/********************************\/<\/p>\n<p>#include<iostream>  <br \/>#include<string>  <br \/>#include<cmath><\/p>\n<p>using namespace std;<\/p>\n<p>const double PE=1E-6;<br \/>const int RESULT = 24;<\/p>\n<p>\/\/F((A,B),C),D)\t<br \/>double num12[6]={0};\t\/\/\u8ba1\u7b97\u7b2c1\u4e2a\u6570\u548c\u7b2c2\u4e2a\u6570<br \/>string exp12[6];\t\t\/\/\u4e24\u4e2a\u6570\u7684\u8868\u8fbe\u5f0f<br \/>double num123[6]={0};\t\/\/\u8ba1\u7b97\u7b2c3\u4e2a\u6570\u548c\u4e0a\u97622\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679c<br \/>string exp123[6];\t\t\/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f<br \/>double numRes1[6]={0};\t\/\/\u8ba1\u7b97\u7b2c4\u4e2a\u6570\u548c\u4e0a\u97623\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679c<br \/>string expRes1[6];\t\t\/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f<\/p>\n<p>\/\/F((A,B),(C,D))<br \/>double num34[6]={0};\t\/\/\u8ba1\u7b97\u7b2c3\u4e2a\u6570\u548c\u7b2c4\u4e2a\u6570<br \/>string exp34[6];\t\t\/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f<br \/>double numRes2[6]={0};\t\/\/\u8ba1\u7b97\u7b2c1\u30012\u6570\u548c\u7b2c3\u30014\u4e2a\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679c<br \/>string expRes2[6];\t\t\/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f<\/p>\n<p>\/\/\u8ba1\u7b97\u4e24\u4e2a\u6570\uff0c\u4fdd\u5b58\u7ed3\u679c\u4e0e\u8868\u8fbe\u5f0f<br \/>void Caculate(double a,double b,double numRes[],string expRes[],string expa,string expb){<br \/>\tnumRes[0]=a+b;<br \/>\texpRes[0]='(&#8216;+expa+&#8217;+&#8217;+expb+&#8217;)&#8217;;<br \/>\tnumRes[1]=a-b;<br \/>\texpRes[1]='(&#8216;+expa+&#8217;-&#8216;+expb+&#8217;)&#8217;;<br \/>\tnumRes[2]=b-a;<br \/>\texpRes[2]='(&#8216;+expb+&#8217;-&#8216;+expa+&#8217;)&#8217;;<br \/>\tnumRes[3]=a*b;<br \/>\texpRes[3]='(&#8216;+expa+&#8217;*&#8217;+expb+&#8217;)&#8217;;<br \/>\tif(b){<br \/>\t\tnumRes[4]=a\/b;<br \/>\t\texpRes[4]='(&#8216;+expa+&#8217;\/&#8217;+expb+&#8217;)&#8217;;<br \/>\t}<br \/>\tif(a){<br \/>\t\tnumRes[5]=b\/a;<br \/>\t\texpRes[5]='(&#8216;+expb+&#8217;\/&#8217;+expa+&#8217;)&#8217;;<br \/>\t}<br \/>}<\/p>\n<p>void main(void){<br \/>\tint com[24][4]={0};<br \/>\tint number[4]={0};<br \/>\tint i,j,m,n,k=0,comNum=0,s=0,flag=1;<\/p>\n<p>\t\/\/\u8f93\u5165\u6570\u636e<br \/>\tfor(i=0;i<4;i++)<br \/>\t\tcin >> number[i];<\/p>\n<p>\t\/\/\u751f\u6210\u6570\u636e\u7684\u6392\u5217\u7ec4\u5408<br \/>\tfor(i=0;i<4;i++){<br \/>\t\tfor(j=0;j<4;j++){<br \/>\t\t\tif(j!=i){<br \/>\t\t\t\tfor(m=0;m<4;m++){<br \/>\t\t\t\t\tif(m!=i&#038;&#038;m!=j){<br \/>\t\t\t\t\t\tfor(n=0;n<4;n++)<br \/>\t\t\t\t\t\t\tif(n!=i&#038;&#038;n!=j&#038;&#038;n!=m){<br \/>\t\t\t\t\t\t\t\tflag=1;<br \/>\t\t\t\t\t\t\t\tfor(s=0;s<k;s++){<br \/>\t\t\t\t\t\t\t\t\tif(com[s][0]==number[i]&#038;&#038;com[s][1]==number[j]&#038;&#038;com[s][2]==number[m]&#038;&#038;com[s][3]==number[n]){<br \/>\t\t\t\t\t\t\t\t\t\tflag=0;<br \/>\t\t\t\t\t\t\t\t\t}<br \/>\t\t\t\t\t\t\t\t}<br \/>\t\t\t\t\t\t\t\tif(flag){\t\t\t\t\t\t\t\t\t<br \/>\t\t\t\t\t\t\t\t\t\tcom[k][0]=number[i];<br \/>\t\t\t\t\t\t\t\t\t\tcom[k][1]=number[j];<br \/>\t\t\t\t\t\t\t\t\t\tcom[k][2]=number[m];<br \/>\t\t\t\t\t\t\t\t\t\tcom[k][3]=number[n];<br \/>\t\t\t\t\t\t\t\t\t\tk++;<br \/>\t\t\t\t\t\t\t\t\t\tcomNum++;<br \/>\t\t\t\t\t\t\t\t}<br \/>\t\t\t\t\t\t\t}<br \/>\t\t\t\t\t}<br \/>\t\t\t\t}<br \/>\t\t\t}<br \/>\t\t}<br \/>\t}<\/p>\n<p>\tfor(i=0;i<comNum;i++){<br \/>\t\tchar buffer[20];<br \/>\t\tstring expa,expb;<br \/>\t\titoa(com[i][0],buffer,10);<br \/>\t\texpa=buffer;<br \/>\t\titoa(com[i][1],buffer,10);<br \/>\t\texpb=buffer;<\/p>\n<p>\t\tCaculate(com[i][0],com[i][1],num12,exp12,expa,expb);<\/p>\n<p>\t\t\/\/F((A,B),C),D)<br \/>\t\tfor(j=0;j<6;j++){<br \/>\t\t\titoa(com[i][2],buffer,10);<br \/>\t\t\texpb=buffer;<br \/>\t\t\tCaculate(num12[j],com[i][2],num123,exp123,exp12[j],expb);<br \/>\t\t\tfor(m=0;m<6;m++){<br \/>\t\t\t\titoa(com[i][3],buffer,10);<br \/>\t\t\t\texpb=buffer;<br \/>\t\t\t\tCaculate(num123[m],com[i][3],numRes1,expRes1,exp123[m],expb);<br \/>\t\t\t\tfor(k=0;k<6;k++){<br \/>\t\t\t\t\tif(fabs(numRes1[k]-RESULT)<PE)<br \/>\t\t\t\t\t\tcout << expRes1[k] << endl;<br \/>\t\t\t}}<br \/>\t\t}<\/p>\n<p>\t\t\/\/F((A,B),(C,D))<br \/>\t\titoa(com[i][2],buffer,10);<br \/>\t\texpa=buffer;<br \/>\t\titoa(com[i][3],buffer,10);<br \/>\t\texpb=buffer;<br \/>\t\tCaculate(com[i][2],com[i][3],num34,exp34,expa,expb);<br \/>\t\tfor(m=0;m<6;m++){<br \/>\t\t\tfor(n=0;n<6;n++){<br \/>\t\t\t\tCaculate(num12[m],num34[n],numRes2,expRes2,exp12[m],exp34[n]);<br \/>\t\t\t\tfor(k=0;k<6;k++)<br \/>\t\t\t\t\tif(fabs(numRes2[k]-RESULT)<PE)<br \/>\t\t\t\t\t\tcout << expRes2[k] << endl;<br \/>\t\t\t}<br \/>\t\t}<br \/>\t}<br \/>}<\/p>\n<\/blockquote>\n<p>\u7cfb\u5217\u6587\u7ae0\uff1a<br \/><a href=\"http:\/\/www.afdream.com\/blog\/blogview.asp?logID=353\" target=\"_blank\" title=\"24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(1)\">24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(1)<\/a><br \/><a href=\"http:\/\/www.afdream.com\/blog\/blogview.asp?logID=354\" target=\"_blank\" title=\"24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(2)\">24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(2)<\/a><br \/><a href=\"http:\/\/www.afdream.com\/blog\/blogview.asp?logID=355\" target=\"_blank\" title=\"24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(3)\">24\u70b9\u7684\u4e09\u79cd\u7b97\u6cd5\u601d\u8def\u53ca\u4ee3\u7801(3)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u516c\u5e03\u4e00\u4e0b\u7b2c\u4e00\u7bc7\u6587\u7ae0\u4e2d\u63d0\u51fa\u7684\u95ee\u9898\u7684\u7b54\u6848\uff1a1,5,5,5\uff1a(5-1\/5)*5=243,3,8,8\uff1a8\/(3-8\/3)=24 \u6b64\u6587\u6240\u8d34\u4ee3\u7801\u5747\u4e3a\u9762\u5411\u8fc7\u7a0b\u7684C(++)\u4ee3\u7801\uff0c\u5728VC6\u4e0b\u7f16\u8bd1\u901a\u8fc7\u3002 \u7b2c\u4e8c\u79cd\u601d\u8def\uff1a \u8fd8\u662f\u5c3d\u91cf\u907f\u514d\u5904\u7406\u62ec\u53f7\uff0c\u5b9e\u5728\u662f\u5f88\u9ebb\u70e6\u3002\u6709\u4e00\u79cd\u6ca1\u6709\u62ec\u53f7\u7684\u8868\u8fbe\u5f0f\u2014\u2014\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\uff08\u540e\u7f00\u8868\u8fbe\u5f0f\uff09\uff0c\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\u4e25\u683c\u5730\u6309\u7167\u4ece\u5de6\u81f3\u53f3\u7684\u987a\u5e8f\u6267\u884c\u3002\u56e0\u6b64\uff0c\u53ea\u9700\u628a\u6240\u6709\u7684\u6570\u5b57\u7684\u6392\u5217\u7ec4\u5408\u4e0e\u6240\u6709\u7684\u7b26\u53f7\u7684\u6392\u5217\u7ec4\u5408\u518d\u8fdb\u884c\u6392\u5217\u7ec4\u5408\u5373\u53ef\u904d\u5386\u6240\u6709\u53ef\u80fd\u7684\u8868\u8fbe\u5f0f\u3002\u5728\u8f93\u51fa\u7ed3\u679c\u65f6\uff0c\u53ea\u9700\u628a\u9006\u6ce2\u5170\u8868\u8fbe\u5f0f\u6309\u7167\u89c4\u5219\u8fd8\u539f\u6210\u6b63\u5e38\u7684\u8868\u8fbe\u5f0f\u5373\u53ef\u3002 \u8bf4\u660e\uff1a&#8217;-&#8216;\u548c&#8217;\/&#8217;\u6709\u4e24\u79cd\u60c5\u51b5\uff0c&#8217;a-b&#8217;\u7528&#8217;a-b&#8217;\u8868\u793a,&#8217;b-a&#8217;\u7528&#8217;a|b&#8217;\u8868\u793a\uff0c&#8217;a\/b&#8217;\u7528&#8217;a\/b&#8217;\u8868\u793a\uff0c&#8217;b\/a&#8217;\u7528&#8217;a\\b&#8217;\u8868\u793a\uff0c&#8217;\\&#8217;\u662f\u8f6c\u4e49\u5b57\u7b26\uff0c\u8981\u7528&#8217;\\\\&#8217;\u8868\u793a\u3002 \u7a0b\u5e8f\u4ee3\u7801\u5982\u4e0b\uff1a \/********************************\/\/* fdream.net *\/\/* Author:Fdream *\/\/* \u5f15\u7528\u6b64\u7b97\u6cd5\u8bf7\u4fdd\u7559\u6b64\u4fe1\u606f *\/\/********************************\/ #include #include #include using namespace std; const double PE=1E-6;const int RESULT = 24; \/\/F((A,B),C),D) double num12[6]={0}; \/\/\u8ba1\u7b97\u7b2c1\u4e2a\u6570\u548c\u7b2c2\u4e2a\u6570string exp12[6]; \/\/\u4e24\u4e2a\u6570\u7684\u8868\u8fbe\u5f0fdouble num123[6]={0}; \/\/\u8ba1\u7b97\u7b2c3\u4e2a\u6570\u548c\u4e0a\u97622\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679cstring exp123[6]; \/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0fdouble numRes1[6]={0}; \/\/\u8ba1\u7b97\u7b2c4\u4e2a\u6570\u548c\u4e0a\u97623\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679cstring expRes1[6]; \/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f \/\/F((A,B),(C,D))double num34[6]={0}; \/\/\u8ba1\u7b97\u7b2c3\u4e2a\u6570\u548c\u7b2c4\u4e2a\u6570string exp34[6]; \/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0fdouble numRes2[6]={0}; \/\/\u8ba1\u7b97\u7b2c1\u30012\u6570\u548c\u7b2c3\u30014\u4e2a\u6570\u8fd0\u7b97\u540e\u7684\u7ed3\u679cstring expRes2[6]; \/\/\u4e0a\u8ff0\u8fd0\u7b97\u7684\u8868\u8fbe\u5f0f \/\/\u8ba1\u7b97\u4e24\u4e2a\u6570\uff0c\u4fdd\u5b58\u7ed3\u679c\u4e0e\u8868\u8fbe\u5f0fvoid Caculate(double a,double b,double numRes[],string expRes[],string &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[212,211],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-coding","tag-212","tag-211"],"views":22834,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=355"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/355\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}