Facebook
From Rude Agouti, 5 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 228
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct point
  6. {
  7.     float x;
  8.     float y;
  9.  
  10.     friend istream &operator>>(istream&, point&);
  11. };
  12.  
  13. istream &operator>>(istream wejscie, point& ex)
  14. {
  15.     wejscie >> ex.x>>ex.y;
  16.   return wejscie;
  17. }
  18.  
  19. class points
  20. {
  21.     point **tab;
  22.     int n;
  23. public:
  24.     friend ostream& operator<<(ostream&, points const&);
  25.  
  26.     points(int size)
  27.     {
  28.         tab = new point*[size];
  29.         for(int i=0; i<size; i++)
  30.         {
  31.             tab[i]=new point;
  32.             tab[i]->x=i;
  33.             tab[i]->y=i+1;
  34.             cout<<tab[i]->x<< " "<< tab[i]->y << endl;
  35.         }
  36.     }
  37. };
  38.  
  39. ostream& operator<<(ostream& wyjscie, points const& ex)
  40. {
  41.     for(int i=0;i<ex.n; i++)
  42.     {
  43.         wyjscie<<ex.tab[i]->x<<endl<<ex.tab[i]->y<<endl;
  44.     }
  45.     return wyjscie;
  46. }
  47.  
  48.  
  49. int main()
  50. {
  51.     point p;
  52.     p.x=10;
  53.     p.y=11;
  54.     cout<<p.x<<endl<<p.y<<endl;
  55.     points pp(5);
  56.     cout<<pp;
  57.  
  58.     system("PAUSE");
  59.     return 0;
  60. }
  61.