| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位高手帮忙看看啊,为什么L老是WA呢?#include<iostream>
#include<cstring>
using namespace std;
char Name[10001][35];
struct Exam{
int score;
char name[35];
}exam[51][10001],tmp[10001];
int Namecmp(const void* a,const void* b){
Exam *c = (Exam *)a;
Exam *d = (Exam *)b;
return strcmp(c->name,d->name);
}
int Scorecmp(const void* a,const void* b){
Exam *c = (Exam *)a;
Exam *d = (Exam *)b;
return d->score- c->score;
}
int main()
{
int N,M,Rank =1;
cin >> N;
getchar();
for(int i = 0; i < N; i++)
cin.getline(Name[i],80,'\n');
cin >> M;
for(int i = 0; i < M; i++){
for(int j = 0; j < N; j++){
cin >> exam[i][j].score;
getchar();
cin.getline(exam[i][j].name,35,'\n');
}
qsort(exam[i],N,sizeof(exam[0][0]),Namecmp);
for(int m = 0; m < N; m++){
for(int k = 0; k <=i; k++){
tmp[m].score = tmp[m].score + exam[k][m].score;
}
strcpy(tmp[m].name,exam[i][m].name);
}
qsort(tmp,N,sizeof(tmp[0]),Scorecmp);
for(int j = 0; j < N; j++){
if(strcmp(tmp[j].name,"Li Ming") == 0){
Rank = j+1;
while(j >=1 && tmp[j].score == tmp[j-1].score){
Rank--;
j--;
}
break;
}
}
cout << Rank << endl;
}
system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator