[Mảng 1 Chiều Cơ Bản]. Bài 19. Lật ngược mảng

View as PDF

Submit solution

Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem source:
28Tech
Problem type
Allowed languages
C, C#, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Cho mảng số nguyên A[] gồm N phần tử, hãy lật ngược mảng A[] và in ra kết quả


Đầu vào

Dòng đầu tiên là số nguyên dương N

Dòng thứ 2 gồm N số nguyên viết cách nhau một vài khoảng trắng


Giới hạn

1<=N<=1000

-10^3<=A[i]<=10^3


Đầu ra

In ra mảng sau khi đã đảo ngược các phần tử


Ví dụ :

Input 01
5
1 2 3 4 5
Output 01
5 4 3 2 1

Comments

Please read the guidelines before commenting.



  • 0
    Khang__  commented on Jan. 25, 2026, 5:27 a.m.

    include <bits/stdc++.h>

    using namespace std;

    define int long long

    const int N=1005; signed main() { ios::syncwithstdio(false); cin.tie(nullptr);

    int n, a[N]; cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int i=n; i>=1; i--) cout<&lt;a[i]<<" ";
    

    }


  • 0
    kietne  commented on Dec. 13, 2025, 2:35 a.m.

    reverse CHO NÓ NHÀN ĐI AE

    include <bits/stdc++.h>

    using namespace std; using ll = long long;

    int main() { ios::syncwithstdio(false); cin.tie(nullptr); // viết code ở đây int n; cin >> n; int a[n]; for (auto &i : a) cin >> i; reverse(a,a+n); for (auto i : a){ cout << i << " "; } return 0; }


  • 0
    L8_DuongThanhKhiem  commented on Nov. 22, 2025, 4:22 a.m.

    Sao các bạn làm dài zậy=))

    #include <bits/stdc++.h>
    using namespace std;
    short n;
    vector <int> a;
    int main() {
        cin >> n;
        a.resize(n);
        for (int i = 0;i < n;i++)cin >> a[i];
        int i = n;
        while (i--){
            cout << a[i] << " ";
        }
        return 0;
    }
    

  • 0
    naipret  commented on Sept. 18, 2025, 7:51 a.m.
    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main() {
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
    
      int num;
      cin >> num;
    
      vector<int> vec(num);
      for (int &ele : vec) {
        cin >> ele;
      }
    
      int idx = num;
      while (idx--) {
        cout << vec[idx] << ' ';
      }
    }
    

  • 0
    hngoc  commented on July 4, 2025, 2:47 p.m.
    n=input()
    a=input().split()
    a.reverse()
    for x in a:
        print(x, end=' ')
    

  • 0
    BaoHuangg  commented on March 7, 2025, 11:33 a.m.

    sao 10 test cuoi bi wa vay mn


  • 0
    bennie15025_meow  commented on Feb. 7, 2025, 1:18 p.m.

    include<bits/stdc++.h>

    using namespace std; vector<long long>a; long long n; int main() { cin>>n; for(int i=1;i<=n;i++) { long long x; cin>>x; a.push_back(x); } reverse(a.begin(),a.end()); for(int i=0;i<a.size();i++) cout<<a[i]<<" "; }


  • 0
    tranquamuop  commented on Nov. 15, 2024, 8:05 a.m.

    include <bits/stdc++.h>

    using namespace std;

    int main() {

    int n,a[10005],i; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=n;i>=1;i--) cout<<a[i]<<" "; return 0; } strong text


  • -20
    huynt  commented on June 7, 2024, 3:31 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -19
    phao_245  commented on May 27, 2024, 4:33 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.