#include <iostream>
#include <fstream>
#include <list>
using namespace std;
int main()
{
int n;
#ifndef ONLINE_JUDGE
ifstream cin("d:\\OJ\\uva_in.txt");
#endif // ONLINE_JUDGE
while (cin >> n) {
list<int> l;
int num;
for (int i = 0; i < n; i++) {
cin >> num;
l.push_back(num);
}
if (n == 0) cout << "NULL" << endl;
else {
for (list<int>::reverse_iterator it = l.rbegin(); it != l.rend(); it++) {
if (it != l.rbegin()) {
cout << " ";
}
cout << *it ;
}
cout << endl;
}
}
return 0;
}
题目1518:反转链表
最新推荐文章于 2020-07-29 00:55:26 发布