验证中...
Languages: C/C++
Categories: 其他
Latest update 2019-03-15 21:22
使用递归
Raw Copy
void fun(int n) {
static int i = 2;
for (; i <= n; ) {
if (n == i) {
cout << i;
return;
} else if (n % i == 0) {
cout << i << '*';
fun(n / i);
break;
}
else
i++;
}
}
类似于筛选法,模i除i
Raw Copy
void fun(int n) {
for(int i=2;i<=n;i++){
while(n%i==0){
if(n!=i)
cout<<i<<'*';
else
cout<<i;
n=n/i;
}
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_sixth 5th_float_left_close