First off, a couple unrelated issues. Arrays are 0-based, so if your array is size 2, you access those 2 elements with myArray[0] and myArray[1]. You are trying to force c++ to work with 1 based indexing, and that's going to cause problems. Change your code to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
constint n = 3;
int apples[n]; // n, not n+1
apples[0] = 73020; // 0, not 1
apples[1] = 63250; // 1, not 2
apples[2] = 102990;// 2, not 3
bsort(n, apples);
for(int i=1;i<n;i++) // <, not <=
{
cout << setw(3) << right << i << " " ;
cout << setw(10) << right << apples[i] << endl;
}
system("pause");
return 0;
}
Next, you are viewing the original index of the integers as some sort of identifier - it's not, it's just the location of the each integer in the apples array. You would have to do something more complicated to keep track of the original index of each integer, but do you really care about that? Will it affect anything later on?
You could create a class/struct that contains bothnumbers. Make the apples array contain objects the class and sort it. That way the two numbers will always stay together.