Advertisement
TPGPL

struktury

Mar 31st, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct pizza
  6. {
  7.     string nazwa;
  8.     float srednica;
  9.     float waga;
  10.  
  11. };
  12. int ile;
  13.  
  14. int main(int argc, char** argv)
  15. {
  16.     cout <<"Ile pizz chcesz stworzyc: ";
  17.     cin>>ile;
  18.     pizza *w = new pizza [ile];
  19.  
  20.  
  21.     for(int i=1; i<=ile; i++ )
  22.     {
  23.         cout <<"Podaj nazwe "<<i<<" pizzy: ";
  24.         cin >>(w)[i-1].nazwa;
  25.         cout <<"Podaj srednice (cm) "<<i<<" pizzy: ";
  26.         cin >>(w)[i-1].srednica;
  27.         cout <<"Podaj wage (dag) "<<i<<" pizzy: ";
  28.         cin >>(w)[i-1].waga;
  29.         cout <<endl;
  30.     }
  31.  
  32.     cout <<"Stworzone pizze:" <<endl<<endl;
  33.  
  34.  
  35.     for(int x=1; x<=ile; x++)
  36.     {
  37.         cout<<x<<". pizza:"<<endl;
  38.         cout<<"Nazwa: "<<(w)[x-1].nazwa<<endl;
  39.         cout<<"Srednica (cm): "<<(w)[x-1].srednica<<endl;
  40.         cout<<"Waga (dag): "<<(w)[x-1].waga<<endl;
  41.         cout<<endl;
  42.     }
  43.  
  44.  
  45.     delete [] w;
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement