Okay I am writing a code that will remove the border of an apmatrix and resize it accordingly
Code:
void RemoveBorder(apmatrix <int> & M)
{
apmatrix<int> temp(100,100);
int Max = M.numrows()-1;
for(int i = 0; i < M.numcols(); i++)
{
M[0][i] = 0;
}
for(int b = 0; b < M.numcols(); b++)
{
M[Max][b] = 0;
}
int Total = M.numrows() - 2;
while(Total > 0)
{
M[Total][0] = 0;
M[Total][M.numcols()] = 0;
Total--;
}
int tempOne = 0;
int tempTwo = 0;
for(int v = 0; v < M.numrows(); i++)
{
for(int s = 0; s < M.numcols(); s++)
{
if(M[v][s] != 0)
{
temp[tempOne][tempTwo] = M[v][s];
tempTwo++;
if(s = M.numcols() - 1)
{
tempOne++;
}
}
}
}
M = temp;
M.resize(tempOne, tempTwo);
for(int c = 0; c < M.numrows(); c++)
{
for (int b = 0; b < M.numcols(); b++)
{
cout << M[c][b] << " ";
}
}
}
Okay for some odd reason I get an infinate loop. I've narrowed it down to the for-loop with the if-statement...can someone tell me whats wrong with it?