Advertisement
Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class meteo{
  5. private:
  6.  
  7. int br;
  8. float temp;
  9. int *niz;
  10. int duz;
  11. public:
  12. meteo(){
  13. niz=0;};
  14. ~meteo(){
  15. delete []niz;
  16. niz=0;
  17. }
  18. meteo(int a,float b,int *c,int d){
  19. br=a;
  20. temp=b;
  21. duz=d;
  22. niz=new int[duz];
  23. for(int i=0;i<duz;i++)
  24. niz[i]=c[i];
  25. }
  26. meteo(const meteo &a){
  27. temp=a.temp;
  28. br=a.br;
  29. duz=a.duz;
  30. niz=new int[a.duz];
  31. for(int i=0;i<duz;i++){
  32. niz[i]=a.niz[i];
  33. }
  34. }
  35. void setBr(int a){
  36. br=a;
  37. }
  38. void setTemp(float b){
  39. temp=b;}
  40. int GetBr(){
  41. return br;
  42. }
  43. int GetTemp(){
  44. return temp;
  45. }
  46. void Stampaj(){
  47. cout<<"Temp"<<temp<<" "<<"broj"<<" "<<br<<" "<<"duzina"<<duz<<endl;
  48. for(int i=0;i<duz;i++)
  49. cout<<niz[i]<<" "<<endl;
  50. }
  51. friend meteo operator+(meteo,meteo);
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. };
  64. meteo operator+(meteo a,meteo b){
  65. int m=0;
  66. int *y=new int[a.duz+b.duz];
  67. for(int i=0;i<a.duz;i++){
  68. y[m++]=a.niz[i];
  69. }
  70. for(int i=0;i<b.duz;i++){
  71. y[m++]=b.niz[i];
  72. }
  73. meteo rez(a.br,a.temp,y,m);
  74. return rez;
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82. }
  83. int main()
  84. {
  85. int a,c,d,e;
  86. float b;
  87. cout<<"Unesi broj i temperaturu"<<endl;
  88. cin>>a>>b;
  89. cout<<"Unesi duzinu niza"<<endl;
  90. cin>>d;
  91. int *x=new int[d];
  92. cout<<"UNESI podatke promjene temp"<<endl;
  93. for(int i=0;i<d;i++){
  94. cin>>e;
  95. x[i]=e;
  96. }
  97. meteo a1(a,b,x,d);
  98. a1.Stampaj();
  99. cout<<"Unesi broj i temperaturu"<<endl;
  100. cin>>a>>b;
  101. cout<<"Unesi duzinu niza"<<endl;
  102. cin>>d;
  103. int *y=new int[d];
  104. cout<<"UNESI podatke promjene temp"<<endl;
  105. for(int i=0;i<d;i++){
  106. cin>>e;
  107. y[i]=e;
  108. }
  109. meteo a2(a,b,y,d);
  110. a2.Stampaj();
  111. meteo a3;
  112. a3=a1+a2;
  113. a3.Stampaj();
  114.  
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement