分解素因子
欢迎进入我的C语言世界
题目
Problem Description
假设x是一个正整数,它的值不超过65535(即1<x<=65535),请编写一个程序,将x分解为若干个素数的乘积。
Input
输入的第一行含一个正整数k (1<=k<=10),表示测试例的个数,后面紧接着k行,每行对应一个测试例,包含一个正整数x。
Output
每个测试例对应一行输出,输出x的素数乘积表示式,式中的素数从小到大排列,两个素数之间用“*”表示乘法。
Sample Input
2
11
9828
Sample Output
11
22333713
答案
下面展示 实现代码
。
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int isPrime(int x)
{
int flag1 = 0;
for(int i = 2; i < x; i++)
{