fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. void Seperate (vector<int> & input);
  6. int main(int argc, char* argv[])
  7. {
  8. vector<int> input;
  9. cout<< "Enter the 10 numbers that you want to be seperated"<<endl;
  10. for(int x=0;x<10;x++)
  11. {
  12. int y;
  13. cin>> y;
  14. input.push_back(y);
  15. }
  16. Seperate(input);
  17. for(int y=0;y<10;y++)
  18. {
  19. cout<< input[y];
  20. }
  21.  
  22. return 0;
  23. }
  24.  
  25. void Seperate (vector<int> &input)
  26. {
  27. string newvec;
  28. int size;
  29. size=input.size();
  30. int start=0;
  31. int end=size;
  32. while (true) {
  33. while ((start != end) && (input[start] % 2 == 0)) {
  34. ++start;
  35. } //This part gets the even numbers.
  36. if (start == end--) break; //Checks if we are done.
  37. while ((start != end) && (input[end] % 2 != 0)) {
  38. --end;
  39. }
  40. if (start == end) break;//Checks if we are done.
  41. swap(input[start++], input[end]);
  42. }
  43. }
Success #stdin #stdout 0s 3476KB
stdin
1 2 3 4 5 6 7 8 9 0
stdout
Enter the 10 numbers that you want to be seperated
0284657391