题解 | #明明的随机数#

明明的随机数

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 ; 
}
全部评论

相关推荐

07-05 16:23
门头沟学院 Java
mengnankk:我投了300,约了5 6个面试。感觉项目写的太多了。一个项目就写五六个亮点,不是把整个项目的功能描述下。其他的没啥,简历看起来有点长
点赞 评论 收藏
分享
07-11 10:56
门头沟学院 Java
码客明:大胆的说自己能实习6个月就行
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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