题解 | #明明的随机数#

明明的随机数

http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

维护一个set,每次输入放入set里面,最后用 set::iterator 遍历一下set。

代码

#include <iostream> 
#include <cstdio>
#include <set> 
using namespace std ; 

set<int> rs ; 
int main(){
    int n ; 
    cin >> n ; 
    for(int i = 0 ; i<n ; i++ ) {
        int x ; 
        cin >> x ;
        rs.insert(x) ; 
    }
    set<int>::iterator it ; 
    for(it = rs.begin() ; it!=rs.end() ;it++ ){
        cout<<*it<<endl; 
    }
    
    
    return 0 ; 
}
全部评论

相关推荐

FOX2003:还没学后端框架吧,看你第一个项目用的mockjs。第一个项目太老而且可能是从github上扒的(我的课设就是这个),第二个主要依靠AI的能力,而且前端项目找前端实习的话,留个github地址好点,主要还是前端要求越来越高了。另外,去***看看,符合就投,boss投的多,HR工作量就大,没功夫多聊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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