30 lines
444 B
C
30 lines
444 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#define MAX 100001
|
||
|
|
||
|
int main(int argc, char **argv) {
|
||
|
|
||
|
int n;
|
||
|
scanf("%d", &n);
|
||
|
|
||
|
int locations[MAX] = {0};
|
||
|
|
||
|
for (int i = 1; i <= n; ++i) {
|
||
|
scanf("%d", &locations[i]);
|
||
|
}
|
||
|
|
||
|
int temp = 0;
|
||
|
for (int i = 1; i <= n; ++i) {
|
||
|
if (locations[i] == i) {
|
||
|
continue;
|
||
|
}
|
||
|
temp = locations[i];
|
||
|
locations[i] = locations[temp];
|
||
|
locations[temp] = temp;
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|