seminar05
This commit is contained in:
parent
1d5f2cac48
commit
c01f40aca3
7 changed files with 108 additions and 1 deletions
18
seminar05_iterators/05_move_spaces/main.cpp
Normal file
18
seminar05_iterators/05_move_spaces/main.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#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;
|
||||
|
||||
}
|
||||
Reference in a new issue