文章

59

粉丝

0

获赞

332

访问

9.6k

头像
递归求阶乘 题解:long long
P1430 北京理工大学/暨南大学机试题
发布于2026年3月12日 17:45
阅读数 63

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll func(ll n)
{
	if(n>1)
		return n*func(n-1);
	else
		return 1;
}
int main()
{
	int m;
	while(cin>>m)
	{
		for(int i=0;i<m;i++)
		{
			ll n;
			cin>>n;
			cout<<func(n)<<endl;
		}
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发