Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct car
- {
- std::string name;
- int year;
- };
- int main()
- {
- int carsintotal;
- std::cout << "Ile samochodow chcesz skatalogowac? ";
- std::cin >> carsintotal;
- car * counted = new car[carsintotal];
- for(int i = 0; i < carsintotal; i++)
- {
- std::cout << "Samochod nr." << i+1 << ":\n";
- std::cout << "Prosze podac marke: ";
- getline(std::cin, counted[i].name);
- std::cin.ignore(256, '\n');
- std::cout << "Prosze podac rok produkcji: ";
- std::cin >> counted[i].year;
- }
- for(int i = 0; i < carsintotal; i++)
- {
- std::cout << counted[i].year <<" ";
- std::cout << counted[i].name;
- std::cout << "\n";
- }
- delete [] counted;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement