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

迭代器遍历容器

https://www.nowcoder.com/practice/0f7ab22e60ee4574a9d9c81412b26595

#include <bits/stdc++.h>
// write your code here......

using namespace std;

vector <int> v;

int main() {
    int x;
    for(int i=0;i<5;i++){
        cin>>x;
        v.push_back(x);
    }
    // write your code here......
    
    for(vector<int>::iterator i = v.begin();i!=v.end();i++){
        cout<<*i<<" ";
    }
    puts("");

    for(vector<int>::iterator i = v.end()-1;i!=v.begin()-1;i--){
        cout<<*i<<" ";
    }
    puts("");

    return 0;
}

全部评论

相关推荐

05-13 00:41
已编辑
北京邮电大学 Java
理性的杰克刷牛客:ai肯定要有的,最好学一下agent方向加一个智能客服什么的进去,并且多加点什么skill,mcp啥的,另外你现在的项目深度有些浅,这些功能都太简单了,而且也不是真正能扛高并发的实现,没有什么太大的亮点,可以去网上找点更有深度的项目。可以先投一些中小厂,有实习经历以后再去大厂,你现在这个大厂可能机会不大
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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