Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <string>
- using namespace std;
- static const int sort_list = 0;
- static const int sort_bush = 1;
- static const int sort_tree = 3;
- struct forest {
- int list;
- int Bush;
- int tree;
- static int sortik;
- forest(){
- list=5;
- Bush=1;
- tree=2;
- }
- forest (int ls,int bh,int tr){
- set_data(ls,bh,tr);
- }
- void set_data(int ls, int bh, int tr){
- list=ls;
- Bush=bh;
- tree=tr;
- }
- void info(){
- cout << "list"<<' '<<list<< endl;
- cout << "Bush"<<' '<<Bush<< endl;
- cout << "tree"<<' '<<tree<< endl;
- }
- bool operator<(forest other){
- if(sortik == sort_list){
- return list<other.list;
- }
- if(sortik==sort_bush){
- return Bush<other.Bush;
- }
- if(sortik==sort_tree){
- return tree<other.tree;
- }
- }
- };
- int forest::sortik = sort_bush;
- int main()
- {
- forest ddt[2];
- ddt[0].set_data(1000,2,1);
- ddt[1].set_data(2,3,3);
- ddt[2].set_data(555,4,3);
- forest::sortik = sort_bush;
- sort(ddt,ddt+ 3);
- for(int i = 0;i<3;i++){
- ddt[i].info();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement