-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresents.cpp
More file actions
39 lines (39 loc) · 798 Bytes
/
presents.cpp
File metadata and controls
39 lines (39 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
// friend 1 ko gift diya friend 2 ne
int brr[n];
for(int i=0;i<n;i++){
brr[i]=arr[i];
}
// brr is a deep copy of arr
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1;j++){
if(brr[j]>brr[j+1]){
int temp;
temp = brr[j];
brr[j] = brr[j+1];
brr[j+1] = temp;
}
}
}
// now brr is sorted
// for(int i=0;i<n;i++){
// cout<<brr[i]<<" ";
// }
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(brr[i]==arr[j]){
cout<<j+1<<" ";
}
}
}
return 0;
}