#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } srand(time(0)); for(int i=n-1;i>=0;i--) { int j=rand()%(i+1); swap(a[j],a[i]); } for(int i=0;i<n;i++) { cout<<a[i]<<" "; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter