#include <iostream>
using namespace std;
int main() {
    int a[]={1,4,5,3,2};
    for(int i=0;i<5;){
        if(a[i]!=i+1)
            swap(a[i],a[a[i]-1]);
        else
            i++;
    }
    for(int i=0;i<5;i++){
        cout<<a[i]<<" ";
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: