整数因子分解

 

#include<bits/stdc++.h>
using namespace std;
//整数因子分解
int total;				//定义为全局变量
void solve(int n)
{
	if (n==1) total++;		//获得一个分解
	else for (int i=2; i<=n; i++)
		if (n%i==0) solve(n/i);
}
int main()
{
int n;
while( scanf("%d",&n)!=EOF)
{
	total = 0;
	solve(n);
	printf("%d\n",total);
}
}
发布了264 篇原创文章 · 获赞 215 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/kt1776133839/article/details/104338164