质因数分解模板

版权声明:本文为博主原创文章,转载请附上注明就行_(:з」∠)_。 https://blog.csdn.net/vocaloid01/article/details/82704903
#include <cstdio>

using namespace std;

void Split(int x){
	for(int i=2 ; i*i<=x ; ++i){
		if(x%i == 0){
			printf("--%d\n",i);//输出质因数 
			while(x%i == 0)x /= i;
		}
	}
	if(x > 1)printf("--%d\n",x);
}

int main(){
	
	int N;
	while(scanf("%d",&N) == 1){
		Split(N);
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/vocaloid01/article/details/82704903