acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 结构体的运用

    userId_undefined

    回来看看

    倔强青铜
    47阅读
    2回复
    1点赞
  • struct utilization

    #include <iostream> #include <vector> #include <algorithm> using namespace std; // 定义一个结构体来存储玩家信息 struct Player { int index; // 玩家序号 int oneStar; // 1星英雄数量 int twoStar; // 2星英雄数量 int threeStar; // 3星英雄数量 int strength; // 阵容强度 }; // 计算阵容强度 int calculateStrength(int oneStar, int twoStar, int threeStar) { return oneStar + twoStar * 3 + threeStar * 9; } // 按照阵容强度排序的比较函数 bool comparePlayers(const Player &a, const Player &b) { if (a.strength != b.strength) { return a.strength > b.strength; // 强度大的在前 } else { return a.index < b.index; // 强度相同,序号小的在前 } } int main() { int n; cin >> n; }

    userId_undefined

    AC狗(=—=)

    倔强青铜
    25阅读
    0回复
    0点赞
  • 谁说得用长代码!!!

    #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<pair<int,int>>p(n); for(int i=0; i<n; ++i) { int a,b,c; cin>>a>>b>>c; p[i]={-(a+3b+9c),i+1}; } sort(p.begin(),p.end()); for(auto& p:p)cout<<p.second<<" "; }//简简单单~~

    userId_undefined

    黑客

    倔强青铜
    1阅读
    0回复
    1点赞
首页