Facebook
From kutas, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 350
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct punkt_2D {
  5.         int x, y;
  6.         char nazwa;
  7.         void wpisz();
  8.         void wypisz();
  9. };
  10.  
  11. struct zbior_punktow {
  12.         int n;
  13.         void wpisz();
  14.         punkt_2D *t = new punkt_2D[n];
  15.         void wypisz();
  16. };
  17.  
  18. int main()
  19. {
  20.         punkt_2D A;
  21.         zbior_punktow B;
  22.  
  23.         B.wpisz();
  24.         zbior_punktow *tab = new zbior_punktow[B.n];
  25.                 for(int i=0; i<B.n;i++)
  26.                 {
  27.                         A.wpisz();
  28.                 tab[i].wpisz();
  29.                 }
  30.         B.wypisz();
  31.                
  32.         system("pause");
  33. }
  34.  
  35. void zbior_punktow::wpisz()
  36. {
  37.         cout << "Ile punktow stworzymy?: ";
  38.         cin >> n;
  39.  
  40. }
  41.  
  42. void punkt_2D::wpisz()
  43. {
  44.         cout << "Podaj wspolrzedne punktu: \n";
  45.         cin >> x >> y;
  46.         cout << "Podaj nazwe punktu: \n";
  47.         cin >> nazwa;
  48. }
  49.  
  50. void punkt_2D::wypisz()
  51. {
  52.         cout << "Podany przez Ciebie punkt to: " << nazwa << "=(" << x << "," << y << ")" << endl;
  53. }
  54.  
  55. void zbior_punktow::wypisz()
  56. {
  57.         for (int i = 0; i < n; i++)
  58.         {
  59.                 cout << t[i].nazwa << " " << t[i].x << " " << t[i].y;
  60.                 cout << endl;
  61.         }
  62.        
  63. }