分解质因子

2 views
Skip to first unread message

bruc...@gmail.com

unread,
Sep 11, 2005, 9:26:21 PM9/11/05
to 星星爱CPP
#include <iostream>
#include <cassert>
using namespace std;
void foo( unsigned int n )
{
assert( n > 1 );
for( int f=2; n!=1; )
{
if( n%f == 0 )
{
cout << f << endl;
n /= f;
}
else ++f;
}
}
int main( void )
{
foo( 52 );

return 0;
}

---

Reply all
Reply to author
Forward
0 new messages