N
N
Nikita Bratsky2018-12-15 15:45:11
C++ / C#
Nikita Bratsky, 2018-12-15 15:45:11

Array name error, although there doesn't seem to be an error, what's the problem?

#include <iostream>
int main(int argc, const char * argv[]) {
    int nach, kol,kol2,i,k,b,c=0;
    std::cin>>nach>>kol>>kol2;
    while (nach!=0) {
        for (i=0; i<kol; i++) {
            int monstersA[kol];
            std::cin>>monstersA[i];
        }
        for (k=0; k<kol2; k++) {
            int monstersB[kol2];
            std::cin>>monstersB[k];
        }
        for (b=0; b<kol*kol2; b++) {
            if (monstersA[b] > monstersB[b]) {
            
            }
        }
    }
}

5c14f74d45665285011981.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-15
@NikBr_9

Must. Move the monsters array declarations out of the for loops.
And read up on scopes. Right now, google "c++ scope" and get enlightened.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question