Răspuns:
Explicație:
#include <iostream>
using namespace std;
struct elem{int num, poz;}v[101];
int n, i,j;
int main()
{
cin >> n;
for (i=1; i<=n; ++i)
{
cin >> v[i].num;
v[i].poz=i;
}
for (i=1; i<n; ++i)
{
for (j=i+1; j<=n; ++j)
{
if (v[i].num>v[j].num) swap(v[i],v[j]);
else
{
if (v[i].num==v[j].num)
{
if (v[i].poz>v[j].poz) swap(v[i],v[j]);
}
}
}
}
for (i=1; i<=n; ++i)
cout << v[i].num << " " << v[i].poz << " ";
}