Cattle brush off network problems 4-- obviously random number c ++

topic

 

 

solution

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main()
{
 
    int num;
    while(cin>>num)
    {
        int temp;
 
        vector<int> hash(1000,0);
        vector<int> ans;
        for(int i=0;i<num;i++)
        {
            cin>>temp;
            hash[temp]++;
            if(hash[temp]==1)
                ans.push_back(temp);
        }
        sort(ans.begin(),ans.end());
        for(int i=0;i<ans.size();i++)
        {
            cout<<ans[i]<<endl;
        }
    }
 
}

 

Published 54 original articles · won praise 29 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_41122796/article/details/104787011