fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main() {
  5. // your code goes here
  6. unsigned int start_index = 4;
  7. unsigned int size = 7;
  8. std::vector<unsigned int> cont;
  9. cont.push_back(start_index);
  10. for (unsigned int i = 0; size - 1 - i >= i; i++)
  11. {
  12. if (i == start_index)
  13. {
  14. i++;
  15. }
  16. //else if (size - 1 - i == start_index)
  17. //{
  18. // i++;
  19. //}
  20. cont.push_back(i);
  21. if (i != size - 1 - i)
  22. {
  23. cont.push_back(size - 1 - i);
  24. }
  25. }
  26.  
  27. for (unsigned int j = 0; j < cont.size(); j++)
  28. {
  29. std::cout << cont[j] << " " << std::endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
4 
0 
6 
1 
5 
2 
4 
3