448,470 Members | 966 Online
Need help? Post your question and get tips & solutions from a community of 448,470 IT Pros & Developers. It's quick & easy.

# My program keeps crashing. The problem seems to be in the for loop or the recursive f

 P: 1 This is the program - its supposed to flood fill a vector, but it keeps crashing upon me running it. The problem seems to be in both the for loops and the fill void Expand|Select|Wrap|Line Numbers #include  #include    using namespace std;     void fill ( vector  > k, int a, int b  ) {     if (k[a][b+1] != 1) {     k[a][b+1] = 1;     fill(k, a, b + 1); }   if (k[a][b-1] != 1) {     k[a][b-1] = 1;     fill(k, a, b); } if (k[a+1][b] != 1) {     k[a + 1][b] = 1;     fill(k, a + 1, b); } if (k[a - 1][b] != 1) {     k[a - 1][b+1] = 1;     fill(k, a - 1, b); } }   int main () {     int a,b; vector  >  op; for ( int i = 0; i < 5; i++ ) {     for ( int j = 0; j < 5; j++) {           cin  >> op[i][j] ;         }     }   cin >> a >> b;   for ( int i = 0; i < 5; i++ ) {     for ( int j = 0; i < 5; j++) {           cout << op[i][j];         }     } fill(op,a,b); } 4 Weeks Ago #1

 100+ P: 110 Line 30,Type miss in for statement Expand|Select|Wrap|Line Numbers for ( int j = 0; j < 5; j++) { Use push_back function or emplace_back function to add elements to the vector. In this case, the size of the vector is fixed (5x5), Declare as follows: Expand|Select|Wrap|Line Numbers vector > op (5, vector  (5));   4 Weeks Ago #2