{ "question_id": 1081343, "question_title": "编写计算组合数的程序?", "question_content": "1.编写计算组合数的程序。\n\n问题分析:\n\n(1)组合数的计算公式为:\n\n \n\n(2)此公式中用到3次阶乘的计算,所以可以编写一个求阶层函数fact(x)。\n\n(3)函数fact(x)的功能为计算整数x的阶层。\n\n要求:上传运行结果截图时,输入n的值为10,m的值为4。程序运行结果参考下图:![图片说明](https://img-ask.csdn.net/upload/202006/07/1591491052_938571.png)", "difficulty": "简单", "answer_id": 1287002, "answer_content": "\n```\n#include <stdio.h>\nint fact(int n)\n{\nint r = 1;\nfor (int i = 1; i <= n; i++) r *= i;\nreturn r;\n}\nint main()\n{\nint m, n;\nscanf(\"%d%d\", &m, &n);\nint c = fact(n) / (fact(m) * fact(n - m));\nprintf(\"c=%d\", c);\nreturn 0;\n}\n```\n# 问题解决的话,请点下采纳", "tag_name": "c语言", "cpp": "#include <stdio.h>\nint fact(int n)\n{\nint r = 1;\nfor (int i = 1; i <= n; i++) r *= i;\nreturn r;\n}\nint main()\n{\nint m, n;\nscanf(\"%d%d\", &m, &n);\nint c = fact(n) / (fact(m) * fact(n - m));\nprintf(\"c=%d\", c);\nreturn 0;\n}", "topic_link": "https://bbs.csdn.net/topics/600469869", "status": 0, "keywords": "算法中阶,摊还分析,聚合分析,高级设计和分析技术", "license": "csdn.net", "notebook": { "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/144.ipynb?type=file" } }