Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- template <class Item> class Wzor{
- static const int size = 6;
- Item Tab_[size];
- int counter_;
- public:
- Wzor(){
- counter_ = 0;
- };
- void addA(Item dodaj){
- if(counter_ <= 6){
- Tab_[counter_] = dodaj;
- counter_++;
- }
- }
- void deleteA(int usun){
- if(counter_ >= usun){
- counter_--;
- Tab_[usun] = Tab_[counter_];
- }
- }
- void show(){
- for (int a = 0; a < counter_; a++){
- for(int i = 0; i < counter_ - 1; i++){
- if(Tab_[i] < Tab_[i + 1]){
- Item tmp;
- tmp = Tab_[i];
- Tab_[i] = Tab_[i + 1];
- Tab_[i + 1] = tmp;
- }
- }
- }
- for(int i = 0; i < counter_ ++; i++){
- Tab_[i].show();
- }
- }
- };
- class Animal{
- string aName_;
- float aWeight_;
- int aBirth_;
- string aId_;
- public:
- Animal(string aName = "0", float aWeight = 0, int aBirth = 0, string aId = "0") : aName_(aName), aWeight_(aWeight), aBirth_(aBirth), aId_(aId){};
- /* Animal show(){
- cout << aName_ << " " << aWeight_ << " " << aBirth_ << " " << aId_ << " ";
- }*/
- void operator = (Animal tottenham){
- aName_ = tottenham.aName_;
- aWeight_ = tottenham.aWeight_;
- aBirth_ = tottenham.aBirth_;
- aId_ = tottenham.aId_;
- }
- bool operator < (Animal tottenham){
- if(aBirth_ < tottenham.aBirth_){
- return true;
- }else if(aBirth_ == tottenham.aBirth_){
- if(aWeight_ > tottenham.aWeight_){
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- };
- class Building{
- string bName_;
- float aGps_;
- float bGps_;
- float bHeight_;
- public:
- Building(string bName = "0", float aGps = 0, float bGps = 0, float bHeight = 0) : bName_(bName), aGps_(aGps), bGps_(bGps), bHeight_(bHeight){};
- /*Building show(){
- cout << bName_ << " " << aGps_ << " " << bGps_ << " " << bHeight_ << " ";
- }*/
- void operator = (Building tottenham){
- bName_ = tottenham.bName_;
- aGps_ = tottenham.aGps_;
- bGps_ = tottenham.bGps_;
- bHeight_ = tottenham.bHeight_;
- }
- bool operator < (Building tottenham)
- {
- if((aGps_ + bGps_) > (tottenham.aGps_ + tottenham.bGps_ )){
- return true;
- }
- else{
- return false;
- }
- }
- };
- int main()
- {
- string Aname[6], Aid[6];
- float Aweight[6];
- int Abirth[6];
- bool liczba;
- for(int i = 0 ; i < 4; i++){
- string temp;
- //nazwa
- do{
- liczba = 1;
- cin >> temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int> (temp[j]) == 32){
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Aname[i] = temp;
- //wiek
- do{
- bool kropka = 1;
- liczba = 1;
- cin >>temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
- }else if(static_cast<int> (temp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Aweight[i] = stof(temp);
- //rok urodzenia
- do{
- liczba = 1;
- cin >>temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
- }
- }
- }while(liczba == 0);
- Abirth[i] = stoi(temp);
- }
- Animal a1(Aname[0], Aweight[0], Abirth[0], Aid[0]);
- Animal a2(Aname[1], Aweight[1], Abirth[1], Aid[1]);
- Animal a3(Aname[2], Aweight[2], Abirth[2], Aid[2]);
- Animal a4(Aname[3], Aweight[3], Abirth[3], Aid[3]);
- Wzor<Animal> animalList;
- animalList.addA(a1);
- animalList.addA(a2);
- animalList.addA(a3);
- animalList.addA(a4);
- string Bname[6];
- float Bgps[6], Bbgps[6], Bheight[6];
- for(int i = 0 ; i < 4; i++){
- string tmp;
- bool liczba;
- bool kropka;
- do{
- liczba = 1;
- cin >> tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int> (tmp[j]) == 32){
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bname[i] = tmp;
- do{
- bool kropka = 0;
- liczba = 1;
- cin >>tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bgps[i] = stof(tmp);
- do{
- kropka = 0;
- liczba = 1;
- cin >>tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bgps[i] = stof(tmp);
- do{
- kropka = 0;
- liczba = 1;
- cin >> tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bheight[i] = stof(tmp);
- }
- Building b1(Bname[0], Bgps[0], Bbgps[0], Bheight[0]);
- Building b2(Bname[1], Bgps[1], Bbgps[1], Bheight[1]);
- Building b3(Bname[2], Bgps[2], Bbgps[2], Bheight[2]);
- Building b4(Bname[3], Bgps[3], Bbgps[3], Bheight[3]);
- Wzor<Building> buildingList;
- buildingList.addA(b1);
- buildingList.addA(b2);
- buildingList.addA(b3);
- buildingList.addA(b4);
- int clear;
- cin >> clear;
- Animal.deleteA(clear);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement