As you can see, I want to find the location of an given array.
For example :
- I have an array {5 , 2, 3, 1} (I want to decide how many guesses I want to guess)
- Then the program will sort it {1, 2, 3, 5}
- At last, I'll be given a chance to guess the number which I desired how many guess (example : I want 2 number guesses, they are 5 and 3. then the program will search for the number 5 and 3. The program will tell me the location in the sorted array. Then it is "3 found at 3, 5 found at 4"
However, I have my code stuck in the sorting
this is my code :
#include <iostream>
using namespace std;
int main(void)
{
int temp, i, j, n, list[100];
cin>>n;
for(i=0; i<n; i++)
{
cin>>list[i];
}
for(i=0; i<n-1; i++)
for(j=i+1; j<n; j++)
if(list[i] > list[j])
{
temp = list[i];
list[i] = list[j];
list[j] = temp;
}
for(i=0; i<n; i++)
cout<<" "<<list[i];
cout<<endl;
return 0;
}
And this link is the full question of my project : http://uva.onlinejudge.org/external/104/p10474.pdf