1083 List Grades (25point(s)) Easy only once

基本思想:

排序弱智题,没什么可说的;

关键点:

无;

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector> 
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
using std::vector;


struct member{
	string a, b;
	int grade;
	bool flag = false;
};

vector<member>list;

int low, high;

bool cmp(member a, member b) {
	if (!a.flag || !b.flag) {
		return a.flag > b.flag;
	}
	if(a.flag&&b.flag)
		return a.grade > b.grade;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		member m;
		cin >> m.a >> m.b >> m.grade;
		list.push_back(m);
	}
	cin >> low >> high;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (list[i].grade >= low && list[i].grade <= high) {
			list[i].flag = true;
			cnt++;
		}
	}
	sort(list.begin(), list.end(), cmp);
	if (cnt == 0)
		cout << "NONE" << endl;
	else {
		//cout << cnt << endl;
		for (int i = 0; i < cnt; i++) {
			printf("%s %s\n",list[i].a.c_str(),list[i].b.c_str(),list[i].grade);
		}
	}
	system("pause");
	return 0;
}

  

猜你喜欢

转载自www.cnblogs.com/songlinxuan/p/12215554.html