// l0.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
using namespace std;
void zhiyinshu(int m, int n)
{
if (m > =n)
{
while (m%n) n++;//#《1》找出质因数
m/=n;//#《2》找出质因数后的m值
zhiyinshu(m, n);//《3》继续找质因数
cout << n << endl;
}
}
int main(int argc, char* argv[])
{
zhiyinshu(50,2);//#1不用考虑,从2开始考虑质因数
return 0;
}
分解质因数
最新推荐文章于 2018-11-30 20:22:26 发布