Advertisement
Guest User

Untitled

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