總時間限制:
1000ms
內存限制:
65536kB
// 在此處補充你的代碼
描述
近年來,國內電視劇吸引了越來越多的關注;有的以當紅的演員陣容而吸引觀衆,比如《三生三世十里桃花》(Life After Life,Blooms Over Blooms);有的以貼近時代的劇情而備受關注,比如《人民的名義》(In the Name of People);有的則以精湛的演技贏得觀衆的喜歡,比如《大明王朝:1566》(Ming Dynasty: 1566)。
你的任務是根據電視劇的不同屬性(演員、劇情和演技)對電視劇進行排行。
#include<iostream>
#include<cstring>
#include<list>
#include<algorithm>
using namespace std;
class TV_Drama{
public:
char name[100];
int actor;
int story;
int acting_skill;
int main(){
list<TV_Drama> lst;
int n;
cin>>n;
char _name[100];
int _actor, _story, _acting_skill;
for (int i=0; i<n; i++){
cin.ignore();
cin.getline(_name,100);
cin>>_actor>>_story>>_acting_skill;
lst.push_back(TV_Drama(_name, _actor, _story, _acting_skill));
}
lst.sort();
for_each(lst.begin(), lst.end(), Printer);
cout<<endl;
lst.sort(comparator_1);
for_each(lst.begin(), lst.end(), Printer);
cout<<endl;
lst.sort(comparator_2());
for_each(lst.begin(), lst.end(), Printer);
cout<<endl;
return 0;
}
輸入
首先輸入整數n,代表電視劇的個數。接下來,對於每個電視劇有兩行輸入:第一行一個字符串(可能含有空格,逗號,冒號等標點符號)作爲電視劇的名字;第二行包括三個整數,分別爲演員陣容、劇情和演技的評分。
輸出
輸出包括三行,分別爲電視劇按演員陣容、劇情和演技的排行榜(評分由高到低),電視劇名字之間以分號隔開
樣例輸入
3
In the Name of People
98 97 99
Life After Life, Blooms Over Blooms
99 82 73
Ming Dynasty: 1566
97 100 100
樣例輸出
Life After Life, Blooms Over Blooms;In the Name of People;Ming Dynasty: 1566;
Ming Dynasty: 1566;In the Name of People;Life After Life, Blooms Over Blooms;
Ming Dynasty: 1566;In the Name of People;Life After Life, Blooms Over Blooms;
// 在此處補充你的代碼
TV_Drama(char *_name, int _actor, int _story, int _ac) :actor(_actor), story(_story), acting_skill(_ac) {
int len = 0;
for (int i = 0; _name[i] != '\0'; i++) {
name[i] = _name[i];
len++;
}
name[len] = '\0';
}
bool operator<(TV_Drama&l) {
return actor > l.actor;
}
};
void Printer(TV_Drama x) {
cout << x.name << ";";
}
bool comparator_1(TV_Drama &x1,TV_Drama &x2) {
return x1.story > x2.story;
}
class comparator_2{
public:
comparator_2() {}
bool operator() (TV_Drama &x1, TV_Drama &x2) {
return x1.acting_skill > x2.acting_skill;
}
};
//