fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main()
  5. {
  6. int n, max, k;
  7. cin >> n;
  8. max=INT_MIN;
  9. vector <int> a(n);
  10. for (int i = 0; i < n; ++i)
  11. cin >> a[i];
  12. for (int i = 0; i < n; ++i)
  13. {
  14. if (a[i] > max)
  15. k = i;
  16. }
  17. swap(a[0], a[k]);
  18. for (int i = 0; i < n; ++i)
  19. cout << a[i]<<' ';
  20. return 0;
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:8:21: error: ‘INT_MIN’ was not declared in this scope
                 max=INT_MIN;
                     ^~~~~~~
stdout
Standard output is empty