| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 148257 | 李明秦 | 成绩排序 | C++ | Compile Error | 0 MS | 0 KB | 1104 | 2026-02-10 16:13:22 |
#include<bits/stdc++.h> using namespace std; struct student { string d; int c; }gra[101]; bool cmp(student x,student y){ if(x.c<y.c)return true; else if(x.c==y.c){ int i=0; while(x.d[i]==y.d[i])i++; if(x.d[i]>y.d[i]) return true; } return false; } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>gra[i].d>>gra[i].c; } for(int i=0;i<n-1;i++){ for(int j=0;j<n-i-1;j++){ if(cmp(gra[j],gra[j+1]))swap(gra[j],gra[j+1]); } } for(int i=0;i<n;i++)cout<<gra[i].d<<" "<<gra[i].c<<endl; return 0; } #include<bits/stdc++.h> using namespace std; struct student { string d; int c; }gra[101]; bool cmp(student x,student y){ if(x.c<y.c)return true; else if(x.c==y.c){ int i=0; while(x.d[i]==y.d[i])i++; if(x.d[i]>y.d[i]) return true; } return false; } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>gra[i].d>>gra[i].c; } for(int i=0;i<n-1;i++){ for(int j=0;j<n-i-1;j++){ if(cmp(gra[j],gra[j+1]))swap(gra[j],gra[j+1]); } } for(int i=0;i<n;i++)cout<<gra[i].d<<" "<<gra[i].c<<endl; return 0; }
Main.cc:32:8: error: redefinition of 'struct student'
struct student {
^
Main.cc:3:8: error: previous definition of 'struct student'
struct student {
^
Main.cc:35:9: error: conflicting declaration 'int gra [101]'
}gra[101];
^
Main.cc:6:2: note: previous declaration as 'student gra [101]'
}gra[101];
^
Main.cc: In function 'bool cmp(student, student)':
Main.cc:36:6: error: redefinition of 'bool cmp(student, student)'
bool cmp(student x,student y){
^
Main.cc:7:6: note: 'bool cmp(student, student)' previously defined here
bool cmp(student x,student y){
^
Main.cc: In function 'int main()':
Main.cc:45:5: error: redefinition of 'int main()'
int main(){
^
Main.cc:16:5: note: 'int main()' previously defined here
int main(){
^