国产探花免费观看_亚洲丰满少妇自慰呻吟_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);}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 胶南市| 海南省| 黄石市| 镇雄县| 伊春市| 永城市| 丽江市| 桦甸市| 始兴县| 济阳县| 张北县| 诏安县| 尼玛县| 商城县| 鲁山县| 明光市| 秦皇岛市| 米林县| 正蓝旗| 松原市| 永胜县| 临沭县| 临漳县| 土默特左旗| 新闻| 毕节市| 韩城市| 安福县| 大连市| 醴陵市| 朝阳县| 淮安市| 昌乐县| 宜兴市| 溧水县| 蓬莱市| 同德县| 博爱县| 同德县| 金川县| 遂宁市|