{"id":397,"date":"2009-05-15T18:16:00","date_gmt":"2009-05-15T10:16:00","guid":{"rendered":""},"modified":"2013-11-24T21:10:28","modified_gmt":"2013-11-24T13:10:28","slug":"c%e8%af%ad%e8%a8%80%e4%bb%8e%e6%96%87%e6%9c%ac%e6%96%87%e4%bb%b6%e4%b8%ad%e8%af%bb%e5%8f%96%e6%95%b0%e6%8d%ae%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/397.html","title":{"rendered":"C\u8bed\u8a00\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6570\u636e\u793a\u4f8b"},"content":{"rendered":"<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &quot;stdafx.h&quot;\r\n#include &quot;stdio.h&quot;\r\n#include &quot;stdlib.h&quot;\r\n#include &quot;math.h&quot;\r\n#define PI 3.1415927;\r\nfloat r1,r2,a,b,h0,r0,u0,x0,M,Q,U,E,temp;\r\nint i=0;\r\n\r\nfloat fromfile(){\r\n FILE *fp;\r\n if ((fp=fopen(&quot;input.txt&quot;,&quot;r&quot;))!=NULL)\r\n {\r\n  fscanf(fp,&quot;%f %f %f %f %f %f %f %f&quot;,&amp;r1,&amp;r2,&amp;a,&amp;b,&amp;h0,&amp;r0,&amp;u0,&amp;x0);\r\n  \/\/printf(&quot;%f %f %f %f %f %f %f %f\\n&quot;,r1,r2,a,b,h0,r0,u0,x0);\r\n  a=a\/180.0*PI;\r\n  b=b\/180.0*PI;\r\n  \/\/printf(&quot;%f %f\\n&quot;,a,b);\r\n }else\r\n {\r\n printf(&quot;file open wrong&quot;);\r\n return 0;\r\n exit;\r\n }\r\n return 1;\r\n}\r\n\r\nvoid suan(float x0)\r\n{\r\n Q=a+b;\r\n U=M*(x0*cos(a)-h0*sin(a))\/pow(float(h0*h0+x0*x0),float(1.5));\r\n E=-M*((h0*h0-2*x0*x0)*cos(a)+3*h0*x0*sin(a))\/pow(float(h0*h0+x0*x0),float(2.5));\r\n}\r\n\r\nvoid outfile(){\r\n \/\/printf(&quot;%f %f %f %f\\n&quot;,Q,M,U,E);\r\n FILE *fp;\r\n if((fp=fopen(&quot;out.txt&quot;,&quot;a&quot;))!=NULL)\r\n {\r\n  fprintf(fp,&quot;%3d \\t%f    %.1f    %f    %f\\n&quot;,i+1,Q,x0,U,E);\r\n  \/\/fprintf(fp,&quot;%f,&quot;,U);\r\n } else\r\n {\r\n  printf(&quot;fail to print&quot;);\r\n }\r\n}\r\n\r\nvoid main()\r\n{\r\n FILE *fp;\r\n if (fromfile())\r\n {\r\n  M=2*r1*r0*r0*u0\/(2*r2+r1);\r\n\r\n  if((fp=fopen(&quot;out.txt&quot;,&quot;w&quot;))!=NULL){\r\n   fprintf(fp,&quot;%s&quot;,&quot;\u7f16\u53f7\\t       Q\\tX\\t     U\\t         E\\n&quot;);\r\n  }\r\n\r\n  for (i;i&lt;400;i++)\r\n  {\r\n   suan(x0);\r\n   outfile();\r\n   x0=x0+0.1;\r\n  }\r\n }\r\n getchar();\r\n\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &quot;stdafx.h&quot; #include &quot;stdio.h&#038;qu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-397","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=397"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/397\/revisions"}],"predecessor-version":[{"id":5193,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/397\/revisions\/5193"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}