Thread: Using an array, problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Registered User
    Join Date
    Oct 2010
    Posts
    79
    I misunderstood my assignment earlier. I now understand for the part with :

    The smallest digit: 0
    Digit 1 can be found in integer number(s): 3

    The largest digit: 9
    Digit 9 can be found in integer number(s): 1, 3

    that the code was supposed to extract the largest and smallest digit. I did that in my code now:

    Code:
    for(i = 0; i < count; i ++){
    		temp = numbers[i];
    		while (temp!= 0){
    			
    			if (temp < 0) {
    				temp = -temp;
    			}
    			numExtract = temp % 10;
    			temp /= 10;
    		
    			if( numExtract > largeDigit ){
    				largeDigit = numExtract;
    				
    			}
    			if( numExtract < smallDigit ){
    				smallDigit = numExtract;
    			}
    			
    			
    		}
    		
    		
    		
    	}
    	cout << "\n";
    	cout << "The smallest digit: " << smallDigit << endl;
    	cout << "The largest digit: " << largeDigit << endl;
    The only thing I need to do now is print out which lines have the smallDigit and largeDigit on them.

    Can anyone please help me? I'm stuck and I don't know what to do. How do I find what line (index) smallDigit and largeDigit are on?? I will appreciate ANY help.
    Last edited by .C-Man.; 03-08-2011 at 08:33 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 08-16-2010, 10:00 AM
  2. Sorting array problem :)
    By BEST in forum C++ Programming
    Replies: 7
    Last Post: 12-11-2009, 01:57 PM
  3. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  4. Array problem
    By TomBoyRacer in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2007, 11:35 AM
  5. Replies: 6
    Last Post: 02-15-2005, 11:20 PM