We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. C++
  3. Introduction
  4. Arrays Introduction
  5. Discussions

Arrays Introduction

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • saimoom1362
    4 months ago+ 0 comments

    C++20:

    #include <iostream>
    using namespace std;
    
    int main() {
        int N, arr[1000];
        
        cin >> N;
        
        for (int i = 0; i < N; i++) {
        cin >> arr[i];
        }
        
        for (int i = 0; i < N / 2; i++) {
        int temp = arr[i];
        arr[i] = arr[N - 1 - i];
        arr[N - 1 - i] = temp;
        }
        
        for (int i = 0; i < N; i++) {
        cout << arr[i] << " ";
        }
        
        return 0;
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy