# include
#include
using namespace std;
int judge(int n);
void main()
{
int n,j,i,t,s;
int static amass=1;
cin>>n;
t=n;
if(judge(n)==1||n==1)
cout<<"你输入的数不是合数"<
{
cout<
{
if((n%i==0)&&judge(i)==1)
{
j=i;
s=0;
while(s==0)
{
cout<
amass*=j;
if (amass!=n)
cout<<"*";
else
cout<
}
}
}
}
}
int judge(int n)
{
int i,j,k,t=1;
k=sqrt(n);
if(n==1)
t=0;
else
{
for(i=2;i<=k;i++)
if(n%i==0)
{
t=0;
break;
}
}
if(t==1)
return 1;
else
return 0;
}
没用到指针,也没有必要用指针啊,如果要用就在定义一个数组,使一个指针指向它,然后把满足条件的因子放入数组中,再用指针输出,但是没什么必要啊,个人认为,有关素数的都没有必要用指针,你自己看看噜!你把它修改一下,这个程序就是没错的,我试验过了,不懂的可追问!
#include
void main()
{
int n,i,a;
cout<<"输入一个正整数"<
cout<
{
a=n%i;
if(a!=0) continue;
else
{
cout< n=n/i;
i-=1;
}
if(n==1)
{
cout<
cout<<"*";
}
}这个简单点!