fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. vector<string> registra_prodotto(int max)
  7. {
  8. vector<string> elements;
  9. string tmp;
  10.  
  11. while (cin >> tmp && max--)
  12. elements.push_back(tmp);
  13.  
  14. return elements;
  15. }
  16.  
  17.  
  18. int main() {
  19. // your code goes here
  20. auto vettore = registra_prodotto(10);
  21.  
  22. cout << "Hai inserito " << vettore.size() << " elementi: " << endl;
  23. for (const auto &i : vettore)
  24. cout << "- " << i << "\n";
  25.  
  26. }
Success #stdin #stdout 0s 3480KB
stdin
Mela
Arancia
Pesca
stdout
Hai inserito 3 elementi: 
- Mela
- Arancia
- Pesca