pat乙级题德才论

// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//

//#include “stdafx.h”

include

include

include

include

include

include

include

include

include

include

using namespace std;

const int MaxSize = 100010;
int Size = 0, Size1 = 0, Size2 = 0, Size3 = 0, Size4 = 0;

typedef struct {
char s[9];
int mark1;
int mark2;
int total;
} Stu, *Stup;

Stu stu[MaxSize], stu1[MaxSize], stu2[MaxSize], stu3[MaxSize], stu4[MaxSize];

bool cmp1(Stu cstu1, Stu cstu2) {
int tmp = strcmp(cstu1.s, cstu2.s);
if (cstu1.total != cstu2.total)
return cstu1.total > cstu2.total;
if (cstu1.mark1 != cstu2.mark1)
return cstu1.mark1 > cstu2.mark1;
if (tmp != 0) return tmp < 0;
return 0;
}

/*bool cmp2(Stu cstu1,Stu cstu2) {
int tmp = strcmp(cstu1.s, cstu2.s);
if()
}*/
void print(Stu *cstu, int len) {
for (int i = 0; i < len; i++) {
printf(“%s %d %d\n”, cstu[i].s, cstu[i].mark1, cstu[i].mark2);
}
}

int main() {
// freopen(“Text.txt”, “r”, stdin);
int n = 0, H = 0, L = 0, M = 0;
while (scanf(“%d %d %d”, &n, &L, &H) != EOF) {
for (int i = 0; i < n; i++) {
scanf(“%s %d %d”, &stu[i].s, &stu[i].mark1, &stu[i].mark2);
stu[i].total = stu[i].mark1 + stu[i].mark2;
if (stu[i].mark1 >= L&&stu[i].mark2 >= L) M++;
if (stu[i].mark1 >= H&&stu[i].mark2 >= H) {
stu1[Size1++] = stu[i];
}
if (stu[i].mark1 >= H&&stu[i].mark2 < H&&stu[i].mark2 >= L) {
stu2[Size2++] = stu[i];
}
if (stu[i].mark1

猜你喜欢

转载自blog.csdn.net/wi8ruk48/article/details/82048292
今日推荐