Here is what I try to do:
The purpose of this program is to find the two smallest elements in several integer arrays, each containing 100 elements. The program will use functions with the prototypes: call the function Two_smallest to find the two smallest elements in the array and their subscripts (if there are two equal smallest elements, detect both – they are solution to the problem); this function MUST leave the original array unchanged; display the two smallest elements with their subscripts in main.
can someone help me or show me how to pass to back to main? and another question is this a correct way to find the two smallest elements in the array? and i dont understand what is this mean?
FYI: English is my 7th lang and I also have a random array already
void two_smallest (int find_array[] , int size3, int *a, int *a2, int *b,int *b2)
{
for (int index = 0; index <= 100; index ++)
{
if (find_array[index] < find_array [0])
{
find_array[0] = find_array [index];
*a = find_array[0];
}
}
cout <<"The first lowest number in this call is " << *a << endl; //testing
for (int index_2=101 ; index_2 < 200; index_2 ++)
{
if (find_array [index_2] < find_array [0])
{
find_array [0] = find_array [index_2];
*b = find_array[0];
}
}
cout <<"The second lowest number is " << *a << endl; // testing