In the above code lis is an array as well as a function name with same return type (int), I didn't get any error, Can anybody explain what is happening in the background? Why is the compiler not showing an error?
int lis( int arr[], int n )
{
int lis[n];
lis[0] = 1;
for (int i = 1; i < n; i++ )
{
lis[i] = 1;
for (int j = 0; j < i; j++ )
if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)
lis[i] = lis[j] + 1;
}
Aucun commentaire:
Enregistrer un commentaire