{
  "question_id": 7430426,
  "question_title": "计算阶乘的和",
  "question_content": "<p>计算1!-2!&#43;3!-4!&#43;5!-6!&#43;7!-8!&#43;9!-10!,并输出计算结果</p>",
  "difficulty": "简单",
  "answer_id": 53397520,
  "answer_content": "<pre>\n<code class=\"language-cpp\">#include &#34;stdio.h&#34;\n\ndouble fun(int n)//用double提高精度和计数位数。\n\n{\n\n    double sum&#61;1.0;\n\n    int i;\n\n    for(i&#61;1;i&lt;&#61;n;i&#43;&#43;)\n\n           sum*&#61;i;\n\n     return sum;\n\n}\n\n \n\nint main()\n\n{\n\n       int i,mark&#61;1;\n\n       double sum&#61;0,item&#61;0;\n\n       for(i&#61;1;i&lt;&#61;10;i&#43;&#43;)\n\n       {\n\n            item&#61;mark*fun(i);\n\n            sum&#43;&#61;item;\n\n            mark&#61;-mark;\n\n       }\n\n       printf(&#34;1!-2!&#43;3!-4!&#43;5!-6!&#43;7!-8!&#43;9!-10!&#61;%.0lf\\n&#34;,sum);\n\n\n\n}</code></pre>\n\n<p> </p>\n",
  "tag_name": "c++",
  "cpp": "#include \"stdio.h\"\ndouble fun(int n)\n{\n\tdouble sum=1.0;\n\tint i;\n\tfor(i=1;i<=n;i++)\n\t\tsum*=i;\n\treturn sum;\n}\nint main()\n{\n\tint i,mark=1;\n\tdouble sum=0,item=0;\n\tfor(i=1;i<=10;i++)\n\t{\n\t\titem=mark*fun(i);\n\t\tsum+=item;\n\t\tmark=-mark;\n\t}\n\tprintf(\"1!-2!+3!-4!+5!-6!+7!-8!+9!-10!=%.0lf\\n\",sum);\n}",
  "topic_link": "https://bbs.csdn.net/topics/600469867",
  "status": 1,
  "keywords": "算法初阶,基础知识,函数的增长,标准记号与常用函数",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/136.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "jason_chan1982"
}