Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Russian");
- cout << "Вводите последовательность чисел \n(чтобы закончить - введите что-угодно, кроме числа):\n";
- vector<double> seq;
- string word = "";
- while (true)
- {
- cin >> word;
- try {
- seq.push_back(stod(word));
- }
- catch(exception& e){
- break;
- }
- }
- size_t size = seq.size();
- size_t items_to_mv = size & 1 ? (size - 1) / 2 : size / 2 - 1;
- for (size_t i = 0; i < items_to_mv; i++) {
- seq.insert(seq.begin() + 2 * i + 1, *(seq.end() - 1 - i));
- }
- seq.erase(seq.end() - items_to_mv, seq.end());
- cout << "Результат: \n";
- for (auto it = seq.begin(); it < seq.end(); it++) {
- cout << *it << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment