fork download
  1. #include <cstdio>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. const int size = 5;
  7. int arr[size] = {1,2,3,4,5};
  8.  
  9. for(int i = 0; i < size;i++)
  10. {
  11. printf("%d ",arr[i]);
  12. }
  13.  
  14. for(int i = 0; i <size-1;i++)
  15. {
  16. int t = arr[i];
  17. arr[i] = arr[size-1];
  18. arr[size-1] = t;
  19. }
  20.  
  21. printf("\n");
  22. for(int i = 0; i < size;i++)
  23. {
  24. printf("%d ",arr[i]);
  25. }
  26. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
5 1 2 3 4