It looks like you need to know how to do this, but I'm kind of unsure, because it's very simple to do...
for(size_t i = DIM1 - 1; i > -1; i--)
{
for( size_t j = DIM2 - 1; j > -1; j-- )
;//...
}
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
Wow I apologize about my previous post--It doesn't work as intended due to the unsigned type used.
I will have to revise my implementation.
for( size_t i = DIM1; i > 0; i-- )
{
for( size_t j = DIM2; j > 0; j-- )
;//Use i-1, j-1.
}
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
You mean you're having trouble getting it to output 8 numbers per line?
void add(int binums[][DIM2], int ans[])
{
const int OUTPUT_MAX_LINE = 8;
int total = 0,
carry = 0,
i = 0,
j = 0,
outputCount = 0;
cout << endl;
for (j = DIM2-1; j >= 0; j--)
{
total = carry;
for (i = 0; i < DIM1; i++)
{
total = total + binums[i][j];
ans[j] = total % 2;
carry = total / 2;
}
if( outputCount < OUTPUT_MAX_LINE )
{
cout << ans[j] << ' ';
outputCount++;
}
else
{
cout << endl << ans[j] << ' ';
outputCount = 0;
}
}
}
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
It sounds like the solution would be to pass the size of array along with the pointer to the array's base.
It seems very hard for me to tell exactly what you're having a problem with. So you have information in your add function that you need to pass to your print_ans() function? Could you point out what you're trying to give to the print_ans() function?
pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111