fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cout<<"Enter the number of the songs: "<<endl;
  7. cin>>n;
  8. int *id= new int[n];
  9. int *revId = new int[n];
  10. cout<<"Enter the Id of each song: " << endl;
  11. for(int i=0;i<n;i++){
  12. cin>>id[i];
  13. }
  14. for(int i=n-1,j=0; j<n ; i--,j++){
  15. revId[j]=id[i];
  16. }
  17. cout<< "the updated version is: ";
  18. for (int i=0 ; i<n;i++){
  19. cout<<revId[i]<<" ";
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 5320KB
stdin
3
1
2
3
stdout
Enter the number of the songs: 
Enter the Id of each song: 
the updated version is: 3 2 1