fork(1) download
  1. #include <bits/stdc++.h>
  2. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  3. using namespace std;
  4. typedef long long ll;
  5. typedef unsigned long long ull;
  6.  
  7. int main() {
  8. IOS;
  9. int n; cin>>n;
  10. int a[n];
  11. int mini=200005,maxi=-200005; //minindex=-1, maxindex=-1;
  12. for(int i=0;i<n;i++){
  13. cin>>a[i];
  14. mini=min(mini,a[i]);
  15. //minindex=i;
  16. maxi=max(maxi,a[i]);
  17. //maxindex=i;
  18. }
  19. swap(mini,maxi);
  20. for(int i=0;i<n;i++) cout<<a[i]<<" ";
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5452KB
stdin
5
4 1 3 10 8
stdout
4 1 3 10 8