解题思路:
list是比较容易被忽略的数据结构,但是其实作用很大
注意事项:
参考代码:
#include <iostream> #include <stdio.h> #include <list> #include <math.h> #include <algorithm> using namespace std; int main(void) { list<int> numList; int num = 0; while (cin >> num) { if (num == 0) break; numList.push_back(num); } numList.reverse(); for (list<int>::iterator it = numList.begin(); it != numList.end(); it++) { if (it == --numList.end()) cout << *it ; else cout << *it << " "; } return 0; }
0.0分
0 人评分
C语言训练-求素数问题 (C语言代码)浏览:720 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:850 |
字符串比较 (C语言代码)答案错误????浏览:596 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1222 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:505 |
WU-陶陶摘苹果2 (C++代码)浏览:968 |
DNA (C语言描述,蓝桥杯)浏览:1553 |
1642题解浏览:709 |
打印十字图 (C语言代码)浏览:2701 |
1012题解浏览:861 |