马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#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;
}
|