标签:lse include temp 记录 mic inf string i++ using
#include <bits/stdc++.h> using namespace std; struct Person{ int score; string name, id, sex; }Girl, Boy, temp; void init(){ Girl.score = 0; Girl.sex = ‘F‘; Boy.score = 100; Boy.sex = ‘M‘; } int main(int argc, char* argv[]) { init(); int n, score; cin >> n; string name, id, sex; bool flag_M, flag_F; flag_M = flag_F = false; for(int i = 0; i < n; i++){ cin >> name >> sex >> id >> score; if(sex == "M"){ flag_M = true; if(score < Boy.score){ Boy.id = id; Boy.name = name; Boy.score = score; } }else if(sex == "F"){ flag_F = true; if(score > Girl.score){ Girl.id = id; Girl.name = name; Girl.score = score; } } } bool flag = false; // 不存在女生 if(flag_F == false){ flag = true; cout << "Absent" << endl; }else{ cout << Girl.name << ‘ ‘ << Girl.id << endl; } // 不存在男生 if(flag_M == false){ flag = true; cout << "Absent" << endl; }else{ cout << Boy.name << ‘ ‘ << Boy.id << endl; } if(flag){ cout << "NA" << endl; }else{ cout << (Boy.score < Girl.score ? Girl.score - Boy.score : Boy.score - Girl.score) << endl; } return 0; }
标签:lse include temp 记录 mic inf string i++ using
原文地址:https://www.cnblogs.com/YC-L/p/12319835.html