题解 | #迭代器遍历容器#

#include <iostream>
// write your code here......
#include <vector>
using namespace std;

int main() {

    // write your code here......
    int num;
    vector<int> nums;
    while(cin >> num){
        nums.emplace_back(num);
    }
    for(auto it = nums.begin(); it != nums.end(); ++it) {
        cout << *it << " ";
    }
    cout << endl;
    for(auto it = nums.end() - 1; it != nums.begin() - 1; --it) {
        cout << *it << " ";
    }

    return 0;
}
全部评论

相关推荐

10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
11-19 18:44
已编辑
成都理工大学 Java
程序员花海:我面试过100+校招生,大厂后端面试不看ACM,竞赛经历含金量低于你有几份大厂实习 这个简历整体来看不错 可以海投
如何写一份好简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务