vendredi 23 mars 2018

how to get multiple index array in a loop c++?

i want the result 1 10 3 8 20 4 how to get multiple index array in a loop ?

int main(){
    int a, b, k;
    int file[7] = {2,1,10,3,8,20,4};
    double count[2];
    for(int i = 1; i <= 2; i++){ 

        a = file[i];
        b = file[i+1];
        k = file[i+2];

        cout << a << "\n";
        cout << b << "\n";
        cout << k << "\n";

    }

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire