zoukankan      html  css  js  c++  java
  • 九度OJ1061

    //C++ sort函数的多重排序
    #include <iostream>
    #include<algorithm>
    #include<string>
    using namespace std;
    typedef struct
    {
        string name;
        int age;
        int score;
    }Student;
    Student stu[1001];
    int cmp(Student s1,Student s2)
    {
        if(s1.score<s2.score)
        return 1;
        else if(s1.score==s2.score)
        {
            if(s1.name<s2.name)
            return 1;
            else if(s1.name==s2.name)
            {
                if(s1.age<s2.age)
                return 1;
                else
                return 0;
            }
            else
            return 0;
        }
        else
        return 0;
    }
    int main()
    {
        int n,i,j;
        while(cin>>n)
        {
            for(i=1;i<=n;i++)
            cin>>stu[i].name>>stu[i].age>>stu[i].score;
            sort(stu+1,stu+n+1,cmp);
            for(i=1;i<=n;i++)
            cout<<stu[i].name<<' '<<stu[i].age<<' '<<stu[i].score<<endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    HTML5新增标签和属性
    HTML——表单标签
    HTML——表格标签
    js
    js
    js
    js
    js-02-2
    js
    selleck --手机端-- 销售打卡记录下载
  • 原文地址:https://www.cnblogs.com/wickedpriest/p/3601670.html
Copyright © 2011-2022 走看看