素因数又写,,,
<我和丈母娘的十年生活> 很好看呀呵呵
贴出代码:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
while (cin >> N)
{
int temp = N;
cout << N << "=";
int cnt = 0;
int flag = 0;
for (int i = 2; i <= sqrt(temp * 1.0); i++)
{
while (temp % i == 0)
{
flag++;
temp = temp / i;
if (!cnt)
{
cnt++;
cout << i;
}
else
{
cout << "*" << i;
}
}
}
if(flag != 0 && temp != 1)
{
cout << "*" << temp;
}
else if (flag == 0 && temp != 1)
{
cout << temp;
}
cout << endl;
}
system("pause");
return 0;
}