#include<iostream> using namespace std; long fac(int n) { long f; if(n == 0 || n == 1) { f = 1; } else { f = fac(n - 1) * n; } return f; } int main ( ) { double z, n, m; cout<<"请输入两个数字:"; cin>> m>> n; if(m < 0 || n < 0 || (m - n) < 0) { cout<< "error!!!"<< endl; } else { z =fac(m) / (fac(n) * fac(m - n)); cout<< z<< endl; } return (0); }
截图:改天补上吧·····
收获:通过这个程序温习了阶乘的求法····还有就是回顾了递推····
感想:完成时遇到了点困难···通过查阅书本才得以解决····有点粗心····