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

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

1062. Talent and Virtue (25)

2019-11-08 18:47:08
字體:
來源:轉載
供稿:網友

對所有數據進行排序,再將其保存到題目各個要求的位置,最后將其輸出

#include<iostream>#include<vector>#include<algorithm>#include<string>#PRagma warning(disable :4996)using namespace std;struct node {//people并創建排列的順序 string id; int V, T; bool Operator<(const node that) const { return (this->V + this->T>that.V + that.T || (this->V + this->T == that.V + that.T && this->V > that.V) || (this->V + this->T == that.V + that.T && this->V == that.V && this->id < that.id)); }};int main(){ vector<node> a, b, c, d, all;//all保存所有的輸入,a,b,c,d分別保存圣人、君子、愚人、小人的人node int N, L, H; cin >> N >> L >> H; all.resize(N); for (int i = 0;i < N;i++) { char t[100]; scanf("%s %d %d", t, &all[i].V, &all[i].T); all[i].id = t; } sort(all.begin(), all.end());//對所有數據先排好序,在一個個輸出到abcd四個容器中 int count = 0; for (auto x : all) { if (x.T >= L &&x.V >= L) { count++; if (x.T >= H &&x.V >= H) a.push_back(x); else if (x.V >= H && x.T < H) b.push_back(x); else if (x.V < H &&x.T < H&&x.V >= x.T) c.push_back(x); else d.push_back(x); } } cout << count << endl;//輸出結果 for (auto x : a) printf("%s %d %d/n", x.id.c_str(), x.V, x.T); for (auto x : b) printf("%s %d %d/n", x.id.c_str(), x.V, x.T); for (auto x : c) printf("%s %d %d/n", x.id.c_str(), x.V, x.T); for (auto x : d) printf("%s %d %d/n", x.id.c_str(), x.V, x.T);}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒙自县| 洪泽县| 正安县| 松桃| 九寨沟县| 泗阳县| 西藏| 个旧市| 太谷县| 龙山县| 伊通| 宜宾市| 长治市| 建瓯市| 大安市| 威宁| 聊城市| 吴川市| 海宁市| 呼伦贝尔市| 宜丰县| 文化| 大丰市| 特克斯县| 涟水县| 临清市| 洛阳市| 建瓯市| 高尔夫| 栖霞市| 开平市| 宾阳县| 鹤峰县| 贵德县| 射洪县| 扎鲁特旗| 宁晋县| 高阳县| 和田市| 河西区| 兴安盟|