G
Gactimus
I made the program below. It outputs the smallest number in the array. What
I would like to know is how do I output the array location. I am at a loss.
For example, since the smallest number in the array is 2, the output should
be 2 for the number and 1 for the location. If anyone could help or point
me in the right direction that would be great. Thanks.
-------------------
#include <iostream>
using namespace std;
int main()
{
int array[3];
array[0] = 5;
array[1] = 2;
array[2] = 10;
int k = 0;
for (int i = 0; i < 3; i++)
if (array < array[i+1])
k = i;
cout << k;
return 0;
}
I would like to know is how do I output the array location. I am at a loss.
For example, since the smallest number in the array is 2, the output should
be 2 for the number and 1 for the location. If anyone could help or point
me in the right direction that would be great. Thanks.
-------------------
#include <iostream>
using namespace std;
int main()
{
int array[3];
array[0] = 5;
array[1] = 2;
array[2] = 10;
int k = 0;
for (int i = 0; i < 3; i++)
if (array < array[i+1])
k = i;
cout << k;
return 0;
}