#include
#include
#include
int zs(long num);
main() {
long num,rest;
char new_num[11];
int i;
while (1) {
printf("输入:");
scanf("%s",&new_num);
printf("\n");
for (i = 0;i < 10 && new_num[i] != '\0';i++) {
if (!isdigit(new_num[i])) {
printf("输入有误,请重试。\n");
goto again;
}
num = atol(new_num);
if (zs(num)) {
print("%d是质数,%d = 1 * %d\n",num,num,num);
goto again;
}
else
while (i < num) {
if (!(rest = num % i)) {
printf("%d * ",i);
if (zs(num /= i)) {
printf("%d\n",num);
goto again;
}
}
else
i++;
}
again:
;
}
}
int zs(long num) {
long i,rest;
for (i = 0;i < (long)sqrt(num);i++)
if (!(rest = num % i))
return 0;
return 1;
}