Nov 22, 2016 at 8:51am UTC
it filter out some numbers from the nested vector i created
Nov 22, 2016 at 8:54am UTC
Can you show us your whole code?
Nov 22, 2016 at 8:56am UTC
Consider this:
1 2 3 4 5
char ch{};
do {
cout << "continue? " ;
cin >> ch;
} while ( ch != 'n' || ch != 'N' );
If I enter 'n',
ch != 'n' -> false
ch != 'N' -> true
If I enter 'N',
ch != 'n' -> true
ch != 'N' -> technically false, as it doesn't get evaluated
As you can see, the logical or operator(||) requires at least one expression to be true, so no matter what I input, the loop will keep running.
I assume it's the same issue with your code.
It might be that you are accessing outside your vector range.
Last edited on Nov 22, 2016 at 8:58am UTC
Nov 22, 2016 at 9:01am UTC
when i add that part of condition it crashes
Nov 22, 2016 at 9:07am UTC
The problem is this one :
if (x[1][j]!=x[2][j] || x[3][j]!=x[4][j] || x[5][j]!=x[6][j] || x[7][j]!=x[8][j] || x[9][j]!=x[10][j] || [x[11][j] != x[12][j] )
Nov 22, 2016 at 9:11am UTC
It might be that you are accessing outside your vector range.
1 2 3 4
for (int i=0;i<12;i++)
{
x.push_back(Fill(int (pow(2,i))));
}
if (x[1][j]!=x[2][j] || x[3][j]!=x[4][j] || x[5][j]!=x[6][j] || x[7][j]!=x[8][j] || x[9][j]!=x[10][j] || x[11][j]!=x[12][j])
You ARE accessing outside your vector range! integralfx is right.
Index of x goes from 0 to 11, not 1 to 12.
There must be a better way of coding that logical statement, though - consider another loop.
Last edited on Nov 22, 2016 at 9:14am UTC