fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <array>
  4.  
  5. using namespace std;
  6.  
  7. void printVector(const vector<int>& vec)
  8. {
  9. for(auto& element : vec)
  10. cout << element << " ";
  11.  
  12. cout << "\n";
  13. }
  14.  
  15. void printArray(const array<int, 5>& arr)
  16. {
  17. for(auto& element : arr)
  18. cout << element << " ";
  19.  
  20. cout << "\n";
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26. vector<int> vec { 1, 2, 3, 4, 5 };
  27. array<int, 5> arr {{ 6, 7, 8, 9, 10 }}; //Die zwei Klammernpaare sind erforderlich
  28.  
  29. printVector(vec);
  30. printArray(arr);
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
6 7 8 9 10