for(i=1; i<=n ;i++ ) //for ease of understanding starting the
array with 1.
{
if(a[ i ] > n )
continue;
else
a[ a [ i ] ]*=n;
}
int x[2], m = 0;
for ( int i = 1; i <=n ; i++)
{
if(a[ i ] % n == 0)
continue;
else
{
x[m++ ] = i;
if(m == 2) break;
}
}
x[] now contain the two missing numbers in ascending order.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---