素因数分解
2013-02-03 19:52
176 查看
素因数又写,,,
<我和丈母娘的十年生活> 很好看呀呵呵
贴出代码:
#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;
}
<我和丈母娘的十年生活> 很好看呀呵呵
贴出代码:
#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;
}
相关文章推荐
- HDU-1492(素因数分解_easy)
- 分解素因数 1
- 分解素因数 2
- 算数基本定理——素因数分解序列生成
- 分解素因数
- HDU 5428 The Factor (素因数分解)
- 机试算法讲解:第26题 分解素因数
- 分解素因数 九度1207 1104 1087
- Hdu 1395 2^x mod n = 1 (欧拉定理 分解素因数)
- poj 1365 Prime Land 素因数分解
- 批量分解素因数(一)
- 复试训练——数学问题—— 分解素因数
- UVA - 10699 - Count the factors(分解素因数)
- poj2407Relatives(欧拉公式,素因数分解)
- 批量分解素因数(二)
- 分解素因数
- C语言:素数筛法与分解素因数
- HDU-1333(分解素因数)
- uva 11396 爪分解,判断所给图是否能分解成爪,二分图判断
- 分解连接