{
  "question_id": 7459909,
  "question_title": "完数",
  "question_content": "<pre>一个数如果恰好等于它的所有因子之和&#xff0c;这个数就称为“完数”。统计自然数 1 — 100 间完数的个数。</pre>",
  "difficulty": "中等",
  "answer_id": 53444950,
  "answer_content": "<p>供参考&#xff1a;</p>\n\n<pre>\n<code class=\"language-cpp\">#include&lt;stdio.h&gt;\n\nint perfect()\n{\n    int i,x,sum,cnt&#61;0;\n    for(i&#61;1;i&lt;&#61;100;i&#43;&#43;)\n    {\n        sum&#61;0;\n        for(x&#61;1;x&lt;i;x&#43;&#43;)\n        {\n            if(i%x&#61;&#61;0)sum&#43;&#61;x;\n        }\n        if(i&#61;&#61;sum)\n        {\n            cnt&#43;&#43;;\n            printf(&#34;%d &#34;,i);\n        }\n    }\n    return cnt;\n}\n\nint main()\n{\n    printf(&#34;\\ncount&#61;%d\\n&#34;,perfect());\n    \n    return 0;\n}</code></pre>\n\n<p> </p>\n",
  "tag_name": "c语言",
  "cpp": "#include<stdio.h>\nint perfect()\n{\n\tint i,x,sum,cnt=0;\n\tfor(i=1;i<=100;i++)\n\t{\n\t\tsum=0;\n\t\tfor(x=1;x<i;x++)\n\t\t{\n\t\t\tif(i%x==0)sum+=x;\n\t\t}\n\t\tif(i==sum)\n\t\t{\n\t\t\tcnt++;\n\t\t\tprintf(\"%d \",i);\n\t\t}\n\t}\n\treturn cnt;\n}\nint main()\n{\n\tprintf(\"\\ncount=%d\\n\",perfect());\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600469960",
  "status": 1,
  "keywords": "算法初阶,基础知识,分治策略,证明主定理,对b的幂证明主定理",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/112.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "weixin_43874743"
}