خرید بک لینک

Vote count: -2

Given the following method

public int countSomething (int[] p)
{
    int count = 0;
    for (int i = 0 ; i < p.length ; i++)
    {
        count++;
        int j = p [i];
        while (j != i)
        {
            j = p [i];
            count++;
        }
    }
    System.out.println (count);
    retu count;

}

int[] arr = {0, 2, 3, 1};

I know countSomething(arr) retus 10 but I am not sure why. Can anyone explain the logic used to retu 10?

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 7 ارديبهشت 1395 ساعت: 20:00

صفحه بندی