This repository has been archived on 2023-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_cpp/seminar05_iterators/05_move_spaces/main.cpp

19 lines
398 B
C++
Raw Normal View History

2022-11-10 16:22:41 +03:00
#include <iostream>
#include <string>
#include <algorithm>
using std::cout, std::string, std::endl;
void move_spaces(string& s) {
std::stable_sort(s.begin(), s.end(), [](const char& a, const char& b){ return (b == ' '); });
}
int main() {
string s;
std::getline(std::cin, s);
move_spaces(s);
// So we can see spaces
cout << s << "###" << endl;
}