国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

1036. Boys vs Girls 解析

2019-11-10 17:11:18
字體:
來源:轉載
供稿:網友

分組排序就好。沒什么好多說的。

#include <iostream>#include <string>#include <vector>#include <algorithm>using namespace std;int N;struct Stu {	string name;	string male;	string id;	int grade;};vector <Stu> male;vector <Stu> femal;bool cmp(Stu s1, Stu s2) {	return s1.grade > s2.grade;}int main() {	cin >> N;	Stu temp;	for (int i = 0; i < N; i++) {		cin >> temp.name >> temp.male >> temp.id >> temp.grade;		if (temp.male == "M") {			male.push_back(temp);		}		else {			femal.push_back(temp);		}	}	sort(male.begin(), male.end(), cmp);	sort(femal.begin(), femal.end(), cmp);	int Mnum = male.size();	int Fnum = femal.size();	bool tag = false;	if (Fnum == 0) {		cout << "Absent" << endl;		tag = true;	}	else {		cout << femal[0].name << " " << femal[0].id <<  endl;	}	if (Mnum == 0) {		cout << "Absent" << endl;		tag = true;	}	else {		cout << male[Mnum - 1].name << " " << male[Mnum - 1].id  << endl;	}		if (tag)		cout << "NA" << endl;	else {		int gap = femal[0].grade - male[Mnum - 1].grade;		if (gap < 0)			gap = -gap;		cout << gap << endl;	}	system("pause");	return 0;	}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 清丰县| 浦城县| 观塘区| 布拖县| 嘉定区| 兴山县| 嘉黎县| 宁化县| 屏山县| 金华市| 桐柏县| 平乡县| 莒南县| 萨嘎县| 宜州市| 项城市| 中超| 札达县| 招远市| 武鸣县| 阆中市| 台中市| 台中县| 讷河市| 灵川县| 朔州市| 外汇| 吉安市| 台北县| 东乌珠穆沁旗| 江永县| 蒙阴县| 岳阳市| 当阳市| 洛南县| 昌黎县| 汝南县| 于都县| 利津县| 兴业县| 绥棱县|