文章目录
- AcWing 816. 数组翻转
- AC代码
AcWing 816. 数组翻转
本题链接:AcWing 816. 数组翻转
本博客给出本题截图:
AC代码
代码:
#include <iostream>using namespace std;void reverse(int a[], int size)
{
for (int i = 0, j = size - 1; i < j; i ++, j -- )swap(a[i], a[j]);
}int main()
{
int a[1000];int n, size;cin >> n >> size;for (int i = 0; i < n; i ++ ) cin >> a[i];reverse(a, size);for (int i = 0; i < n; i ++ ) cout << a[i] << ' ';return 0;
}