-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList_using_Array_Example_2.c
82 lines (55 loc) · 1.96 KB
/
List_using_Array_Example_2.c
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Students of class CSE are given an array A of positive integers of size N. The student’s task is to sort the array in increasing order and print out the original index position of the newly sorted array.
// NOTE: The indexing of the array starts with 0.
// Example:
// A={4,5,3,7,1}
// After sorting the new array becomes A={1,3,4,5,7}.
// The required output should be "4 2 0 1 3"
// INPUT :
// The first line of input consists of the size of the array A
// The next line consists of the array of size N
// OUTPUT :
// Output consists of a single line of integers
// CONSTRAINTS:
// 1<=N<=10^6
// 0<=A[i]<=10^6
// Sample Input 1
// Input:
// 5
// 12 3 87 14 65
// Output:
// 1 0 3 4 2
// Sample Input 2
// Input:
// 7
// 12 23 32 45 56 67 89
// Output:
// 0 1 2 3 4 5 6
#include<stdio.h>
int main()
{
int n,a[100],b[100],temp;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[i]=a[i];
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]>a[j]){
temp=a[j];
a[j]=a[i];
a[i]=temp;}
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i]==b[j])
printf("%d ",j);
}
}
}