题目描述
由于刚学了STL,所以想到了用vector和reverse直接解
算法1
(暴力枚举) $O(n^2)$
C++ 代码
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int b[20];
int main()
{
for (int i = 0 ; i < 20 ; i ++) cin >> b[i];
vector<int> a;
for (int i = 0 ; i < 20 ; i ++) a.push_back(b[i]);
reverse(a.begin(),a.end());
for (int i = 0 ; i < 20 ; ++ i) printf("N[%d] = %d\n",i,a[i]);
return 0;
}