Write one more function to return the number of digits in one of the arrays. Have it return the index of the leftmost digit. Call this function on each array and remember the lowest value (the leftmost digit of the 'largest' value).
Pass this value into the print function. You can take it from there.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Consider using a named constant to replace the 'magic number' 26 whic appears at several places in your code.What would you do if you need to modify your program to deal with 100-digit integers tomorrow?
enum { NDIGITS = 26, LAST_DIGIT = NDIGITS-1 } ;
I know that I can use a count variable to right justify these numbers like the professor wants, i just cannot for the life of me figure out how to implement it or how to do it a different way.
Just modify your print function to print a space when leading zeros are encountered.
void printarray( int arg[] )
{
int i = 0 ;
for( ; i<LAST_DIGIT && arg[i]==0 ; ++i ) std::cout << ' ' ;
for( ; i<LAST_DIGIT ; ++i ) std::cout << arg[i] ;
std::cout << arg[LAST_DIGIT] << '\n' ; // print the last digit even if it is zero
}
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287