Here's how the output should look:
Select an option (1, 2, or 3): 2
How many integers? 3
Enter integer #1: 12795
Enter integer #2: -20784
Enter integer #3: -27904
The smallest digit: 0 Digit 0 can be found in integer number(s): 2, 3
The largest digit: 9 Digit 9 can be found in integer number(s): 1, 3
It's giving me 3 separate largest and smallest digits (one for each member of the array) how would I go about making the program compare the numbers amongst themselves to decide which over all is the largest or smallest and only reply with one set for the whole array? What am I missing so the digits will be compared properly ? Thank you
this is the output :
How many integers?
Enter integer #1: 231
Enter integer #2: 456
Enter integer #3: 987
The smallest digit is: 2
The greatest digit is: 3
He is trying to:
1) Ask user for amount of integers
2) input n amount of integers
3) find the largest digit in all of the integers
4) output the largest digit and all the integers it can be found in
5) repeat 3 and 4 for smallest
ex
3 integers
1 , 23 , 321
largest digit = 3
largest digit is found in integer 2 and 3
smallest digit 1
smallest digit is found in integer 1 and 3
He would have to do something basically to break an integer down into digits like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
int main()
{
int input = 0;
std::cout << "Please enter an integer: ";
std::cin >> input;
std::cout << "The digits for " << input << " are: ";
while( input > 9 )
{
std::cout << input % 10;
input /= 10;
}
std::cout << input << std::endl;
}
Then assign those digits to an array of some sort or a container then check the largest/smallest digits manually or using the std::min_element and std::max_element.