分解质因数,学习学习呦
#include <iostream>#include <cmath>
using namespace std;
int main(/*int argc, _TCHAR* argv[]*/)
{
double num = 0, num1 = 0, num2 = 0, i = 2;
double a = 1;
cout << "Cin>>";
cin >> num;
go:
for (; a != 0; i++)
{
a = (num / i) - ceil(num / i);
//cout << i <<endl<<a<< endl;
if (a == 0)
{
num1 = i;
num2 = num / num1;
double i2 = 2;
if (num2 == 1)
{
cout << num1 << endl;
break;
}
for (; ((num2 / i2) - ceil(num2 / i2)) != 0; i2++);
if (((num2 / i2) - ceil(num2 / i2)) == 0)
{
i = i2;
a = 1;
num = num2;
cout << num1 << "x";
goto go;
}
else
{
cout << num1 << "x" << num2 << endl;
break;
}
}
if (i > num)
{
cout << "输入有误!" << endl;
break;
}
}
main();
return 0;
} 虽说挺简单的但还是支持一下了 O(∩_∩)O~ 我只是路过打酱油的
页:
[1]