int main() { int n; cout << "Enter the number of elements in the array: "; cin >> n;
int arr[n]; cout << "Enter the elements of the array: "; for (int i = 0; i < n; i++) { cin >> arr[i]; } cout << "Array in reverse order: "; for (int i = n - 1; i >= 0; i--) { cout << arr[i] << " "; } return 0;
}
// Пример работы: // Enter the number of elements in the array: 5 // Enter the elements of the array: 1 2 3 4 5 // Array in reverse order: 5 4 3 2 1
using namespace std;
int main() {
int arr[n];int n;
cout << "Enter the number of elements in the array: ";
cin >> n;
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cout << "Array in reverse order: ";
for (int i = n - 1; i >= 0; i--) {
cout << arr[i] << " ";
}
return 0;
}
// Пример работы:
// Enter the number of elements in the array: 5
// Enter the elements of the array: 1 2 3 4 5
// Array in reverse order: 5 4 3 2 1