dimanche 26 juin 2016

Could someone please help me understand this code?

I'm trying to teach myself coding, and I stumbled on an example I don't understand. Could someone give me an overview of what this code is supposed to do? I'm a bit confused about int a[] and what is later int a[i]. I know what an array is, but could someone please explain how this is being used in this context? Thank you in advance.

public class all {

    public int select(int a[],int n,int x)
        {
            int i=0;
            while(i<n && a[i]<x)
            {
                if(a[i]<0)
                    a[i]=-a[i];
                i++;
            }
            return(a[i-1]);
        }

}

Aucun commentaire:

Enregistrer un commentaire