tuki2501

bai_1.cpp

Jan 27th, 2021 (edited)
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, a[100], sum = 0;
  6.   cout << "Nhap n: "; cin >> n;
  7.   for (int i = 0; i < n; i++) {
  8.     cout << "Nhap a[" << i << "] = ";
  9.     cin >> a[i];
  10.     sum += a[i];
  11.   }
  12.   cout << "Tong cac phan tu: " << sum << '\n';
  13.   cout << "Mang a in theo thu tu nguoc lai: ";
  14.   for (int i = n - 1; i >= 0; i--) {
  15.     cout << a[i] << ' ';
  16.   }
  17.   cout << '\n';
  18.   return 0;
  19. }
Add Comment
Please, Sign In to add comment