●阶乘
#include<iostream> using namespace std; class digui { public: long long fact(int x) { if (x == 1) { return (this->result = 1); } else { return (this->result=x*fact(x-1)); } } void showresult() { cout << this->result << endl; } int a; long long result; }; void func() { digui dg; cin>>dg.a; dg.fact(dg.a); dg.showresult(); } int main() { func(); }