首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月21日 15:59
成绩排序2.0 题解:
P1159
回复 0
|
赞 3
|
浏览 77
#include<bits/stdc++.h> using namespace std; struct student{ int co; int score; }stu[1000]; bool cmp(student a,student b){ if(a.score==b.score) {return a.co < b.co; } else { return a.score < b.score; } } int main(){ int n,i; cin>>n; for(i=0;i<n;...
山崎友希
2025年3月12日 16:33
成绩排序2.0 题解:
P1159
回复 0
|
赞 3
|
浏览 138
#include<stdio.h> typedef struct{ int p;//学号 int q;//成绩 }student; int main(){ int N; scanf("%d",&N); student a[N]; int i=0,j=0;  ...
XCR553
2025年3月12日 10:10
成绩排序2.0 题解:
P1159
回复 0
|
赞 1
|
浏览 130
冒泡排序 #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[2*n]; for(int i = 0; i + 1 < 2*n; i += 2){ ci...
zxjrheaven
2025年3月9日 22:53
成绩排序2.0 题解:暴力至高
P1159
回复 0
|
赞 5
|
浏览 112
#include <bits/stdc++.h> using namespace std; struct student { int num; int score; }stu[100]; bool cmp(student a,student b) { if(a.score==b.score)return a.num<b.num; else return a.score<b.score; ...
shiv15832
2025年3月9日 17:52
成绩排序2.0 题解:
P1159
回复 0
|
赞 5
|
浏览 197
比较简单的题,最好想的思路就是定义一个结构体,包含num,和score。输入后用sort函数排序,需要注意 1:cmp函数逻辑不能出错,cmp的逻辑是:如果成绩相等,返回num小的;(else)如果成绩不等,返回成绩小的。 代码:int cmp(Stu a,Stu b){ if(a.score == b.score) return a.num < b.num; else return a.score < b.score; } 2:如果输入的时候,for循环从int i = 1...
固态氧化碳
2025年2月15日 10:54
成绩排序2.0 题解:记录一下
P1159
回复 1
|
赞 20
|
浏览 377
#include <iostream> #include <algorithm> using namespace std; typedef struct student { int p; int grade; } stu; bool compare(stu a, stu b) { if (a.grade == b.grade) { return a.p < b.p; // 成绩相同则按学号升序 &...
ccccccyes
2024年9月7日 21:11
成绩排序2.0 题解:
P1159
回复 0
|
赞 8
|
浏览 842
//07/09/24 21:00 // #include <iostream> #include <algorithm> using namespace std; struct student{ int p; int q; } stu[105]; //默认排序就是从小到大的 bool cmp(student a,student b){ if(a.q == b.q) return a.p < b.p; else return a.q < b.q; } int main(){ i...
yang61
2024年6月17日 17:13
成绩排序2.0 题解:
P1159
回复 1
|
赞 0
|
浏览 748
为什么不能这样写?在我自己电脑可以输出啊 #include<bits/stdc++.h> using namespace std; int main(){ int n; int no,score; cin >>n; int a[105]={0}; for(int i=1;i<=n;i++){ cin >>no>> sco...
trmbh
2024年6月14日 18:30
成绩排序2.0 题解:
P1159
回复 0
|
赞 0
|
浏览 716
可以采用重载符号运算符的方式(sort默认会采用 < 的比较方式,也就是less) #include<bits/stdc++.h> using namespace std; class Student { public: int id, score; Student(int sid, int sscore) : id(sid), score(sscore) {} bool operator<(const Student &other) const { if (score != ...
Candour
2024年4月28日 23:29
成绩排序2.0 (C++)题解:
P1159
回复 0
|
赞 3
|
浏览 656
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 110; PII s[N]; int n; bool cmp(PII a, PII b) { if(a.second == b.second) return a.first < b.first; else return a.second < b.second; } int main() { cin >> ...
1
2
3
4
题目
成绩排序2.0
题解数量
36
发布题解
在线答疑
热门题解
1
成绩排序2.0 题解:记录一下
2
成绩排序2.0 题解:
3
成绩排序2.0 题解:
4
成绩排序2.0 题解:为什么通过数据只有75%啊 球球了 帮我找出错误测试数据吧 感谢
5
成绩排序2.0 题解:改了好多次了,一直都通过不了
6
成绩排序2.0 题解:
7
成绩排序2.0 题解:暴力至高
8
成绩排序2.0 题解:
9
成绩排序2.0 (C++)题解:
10
成绩排序2.0 题解: