CPlusPlusThings/practical_exercises/10_day_practice/day2/递归1.cpp
Light-City a4d828bb4c update
2020-04-06 00:57:02 +08:00

25 lines
309 B
C++

#include<iostream>
using namespace std;
int f(int n);
int main(int argc, char const *argv[])
{
cout<<"input x:";
int x;
cin>>x;
cout<<f(x)<<endl;
system("pause");
return 0;
}
int f(int n)
{
if(n==0)
{
return 1;
}
else
{
return n*f(n-1);
}
}