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

Posted songlinxuan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
",list[i].a.c_str(),list[i].b.c_str(),list[i].grade);
		}
	}
	system("pause");
	return 0;
}

  

以上是关于1083 List Grades (25point(s)) Easy only once的主要内容,如果未能解决你的问题,请参考以下文章

1083 List Grades (25 分)排序

1083. List Grades (25)

1083. List Grades (25)

PAT 甲级 1083 List Grades (25 分)

A1083 List Grades (25 分)

PAT(A) 1083. List Grades (25)