请问这个哪里有问题?
#include<stdio.h>//质因子分解
int main(void)
{
int num,i=2,temp,first_num=1;
scanf("%d",&num);
temp=num;
while(temp)
{
while(temp&&temp%i==0)
{
if(first_num)
{
printf("%d",i);
first_num=0;
}
else
{
printf("*%d",i);
}
temp/=i;
}
i++;
}
return 0;
} 本帖最后由 jackz007 于 2021-9-25 20:19 编辑
#include<stdio.h>
int main(void)
{
int num , i = 2 , temp , first_num = 1 ;
scanf("%d" , & num) ;
temp = num ;
while(temp && i <= temp)
{
if(temp && temp % i == 0)
{
if(first_num)
{
printf("%d",i);
first_num=0;
}
else
{
printf("*%d",i);
}
temp /= i ;
} else {
i ++ ;
}
}
return 0;
}
编译、运行实况
D:\00.Excise\C>g++ -o x x.c
D:\00.Excise\C>x
6
2*3
D:\00.Excise\C>x
60
2*2*3*5
D:\00.Excise\C>x
240
2*2*2*2*3*5
D:\00.Excise\C>x
1680
2*2*2*2*3*5*7
D:\00.Excise\C>x
113
113
D:\00.Excise\C>
页:
[1]