超级丶咸鱼


私信TA

用户名:qjq7572757

访问量:2090

签 名:

等  级
排  名 3137
经  验 1942
参赛次数 2
文章发表 3
年  龄 18
在职情况 学生
学  校 华南农业大学
专  业 软件工程

  自我简介:

解题思路:STL

注意事项:

参考代码:

#include <iostream>

#include <list>


using namespace std;


typedef struct student

{

    int id;

    double score;

    bool operator <(const student &a)const

    {

        if(id<a.id)

            return true;

        else

            return false;

    }

}student;


void output(list<student> t)

{

    for(list<student>::iterator it=t.begin();it!=t.end();it++)

    {

        cout<<(*it).id<<' '<<(*it).score<<endl;

    }

}


int main()

{

    list<student> s1,s2;

    student s;

    int n,m;

    cin>>n>>m;

    for(int i=1;i<=n;i++)

    {

        cin>>s.id>>s.score;

        s1.push_back(s);

    }

    for(int i=1;i<=m;i++)

    {

        cin>>s.id>>s.score;

        s2.push_back(s);

    }

    s1.sort();

    s2.sort();

    s1.merge(s2);

    output(s1);

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区