Advertisement
Guest User

c++

a guest
Jun 25th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. struct car
  5. {
  6.     std::string name;
  7.     int year;
  8. };
  9. int main()
  10. {
  11.     int carsintotal;
  12.     std::cout << "Ile samochodow chcesz skatalogowac? ";
  13.     std::cin >> carsintotal;
  14.     car * counted = new car[carsintotal];
  15.     for (int i = 0; i < carsintotal; i++)
  16.     {
  17.         std::cout << "Samochod nr." << i + 1 << ":\n";
  18.         std::cout << "Prosze podac marke: ";
  19.         std::cin >> counted[i].name;
  20.         std::cout << "Prosze podac rok produkcji: ";
  21.         std::cin >> counted[i].year;
  22.     }
  23.     for (int i = 0; i < carsintotal; i++)
  24.     {
  25.         std::cout << counted[i].year << " " << counted[i].name << std::endl;
  26.  
  27.     }
  28.  
  29.     system("pause");
  30.  
  31.     delete[] counted;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement