Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void uporzadkuj(vector<int> & wek)
- {
- int roz_wek = wek.size();
- int l = 0;
- int p = roz_wek;
- while (p > l){
- while(wek[l] % 2 == 1)
- {
- l++;
- }
- while(wek[p] % 2 == 0)
- {
- p--;
- }
- if(l < p)
- {
- swap(wek[l], wek[p]);
- l++;
- p--;
- }
- }
- }
- int main()
- {
- vector<int> v(6);
- v[0] = 1;
- v[1] = 2;
- v[2] = 3;
- v[3] = 4;
- v[4] = 5;
- v[5] = 6;
- for(auto x: v)
- {
- cout << x << endl;
- }
- cout << "--------" << endl;
- uporzadkuj(v);
- for(auto x: v)
- {
- cout << x << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement