lundi 24 avril 2017

can't enter the "if" condition . why?

this is a function I wrote , it sorts a few arrays based on the number at index 0 in every array- because in every array , the number at index 0 equals to the amount of numbers in the array(length). and it never enters the simple "if" statement even though it should because the number at index 0 in the first array IS bigger than the number at index 0 in the second array.

    void orderSorting(int ** parr,int rows)
    {
        int i, *temp;
        for (i = 0; i < rows-1; i++)
        {
            if (parr[i][0] > parr[i + i][0])
            {
                temp = *(parr + i + 1);
                *(parr + i + 1) = *(parr + i);
                *(parr + i) = temp;
            }
        }
    }

Aucun commentaire:

Enregistrer un commentaire