fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4.  
  5. //using namespace std;
  6. std::vector < int > oddNumbers(int l, int r) {
  7. std::vector<int>v(r-l + 1);
  8. int k = 0;
  9. for (int i=l; i<=r; i++)
  10. {
  11. if (i % 2 != 0 )
  12. {
  13. v[k] = i;
  14. k++;
  15. }
  16.  
  17. }
  18. return v;
  19. }
  20. int main() {
  21. std::vector<int> v = oddNumbers(3,9);
  22. std::cout << "Hello" << "\n";
  23. for( auto idx=0; idx < v.size(); ++idx){
  24. std::cout << v[idx] << ", ";
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Hello
3, 5, 7, 9, 0, 0, 0,