Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <string>
  5. using namespace std;
  6. static const int sort_list = 0;
  7. static const int sort_bush = 1;
  8. static const int sort_tree = 3;
  9. struct forest {
  10. int list;
  11. int Bush;
  12. int tree;
  13. static int sortik;
  14. forest(){
  15. list=5;
  16. Bush=1;
  17. tree=2;
  18.  
  19. }
  20. forest (int ls,int bh,int tr){
  21. set_data(ls,bh,tr);
  22. }
  23. void set_data(int ls, int bh, int tr){
  24. list=ls;
  25. Bush=bh;
  26. tree=tr;
  27. }
  28. void info(){
  29. cout << "list"<<' '<<list<< endl;
  30. cout << "Bush"<<' '<<Bush<< endl;
  31. cout << "tree"<<' '<<tree<< endl;
  32. }
  33. bool operator<(forest other){
  34. if(sortik == sort_list){
  35. return list<other.list;
  36. }
  37. if(sortik==sort_bush){
  38. return Bush<other.Bush;
  39. }
  40. if(sortik==sort_tree){
  41. return tree<other.tree;
  42. }
  43. }
  44.  
  45. };
  46. int forest::sortik = sort_bush;
  47. int main()
  48. {
  49.  
  50.  
  51. forest ddt[2];
  52. ddt[0].set_data(1000,2,1);
  53. ddt[1].set_data(2,3,3);
  54. ddt[2].set_data(555,4,3);
  55. forest::sortik = sort_bush;
  56. sort(ddt,ddt+ 3);
  57. for(int i = 0;i<3;i++){
  58. ddt[i].info();
  59. }
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement