主题:[讨论]求助,质数分解
帮我看下这段代码:
[code=c]
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
void funa ( int n ) ;
int main( void )
{
int n ;
scanf( "%d",&n ) ;
funa(n);
system( "pause" );
return 0 ;
}
void funa ( int n )
{
int i = 3 ;
int q = sqrt( n ) ;
printf( "\n" );
for ( ;!(n&1);n>>=1 )
if ( n==2 )
{
printf( "2\n" ) ;
return;
}
else printf( "2*" );
for( ; ; )
{
if(n%i==0)
if((n/=i)>i)
{
printf( "%d*",i );
}
else
{
printf( "%d\n",i );
return ;
}
else if ( (i+=1)>=q )
{
printf( "\n" );
return ;
}
}
}
[/code]
[code=c]
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
void funa ( int n ) ;
int main( void )
{
int n ;
scanf( "%d",&n ) ;
funa(n);
system( "pause" );
return 0 ;
}
void funa ( int n )
{
int i = 3 ;
int q = sqrt( n ) ;
printf( "\n" );
for ( ;!(n&1);n>>=1 )
if ( n==2 )
{
printf( "2\n" ) ;
return;
}
else printf( "2*" );
for( ; ; )
{
if(n%i==0)
if((n/=i)>i)
{
printf( "%d*",i );
}
else
{
printf( "%d\n",i );
return ;
}
else if ( (i+=1)>=q )
{
printf( "\n" );
return ;
}
}
}
[/code]