《面试准备》中兴2018笔试题

 《面试准备》中兴2018笔试题_第1张图片

#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

int output;
struct salary{
    int money;
    int cnt;
};
bool findx(const salary &s){
    return s.money == output;
}
bool cmp(const salary &s1,const salary &s2){
    if(s1.cnt==s2.cnt)
        return s1.money>s2.money;
    else{
        return s1.cnt>s2.cnt;
    }
}
int main()
{
    vectorsal;
    salary mysal;
    stringstream ss;
    string s = "200,300,100,200,100,300,100,200,300,100,200,100,300";
    string num;
    ss<>output;
	    auto f = find_if(sal.begin(),sal.end(),findx);
	    if(f!=sal.end())
            f->cnt++;
        else{
            mysal.cnt = 1;
            mysal.money = output;
            sal.push_back(mysal);
        }
	}
    sort(sal.begin(),sal.end(),cmp);
	for(auto it=sal.begin();it!=sal.end();it++){
        cout<money<<" : "<cnt<

 

你可能感兴趣的:(笔试)