Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
задача new
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include <iostream> #include <list> #include <iterator> #include <limits> int main() { const size_t AMOUNT_TO_ENTER = 6; std::list<int> elems{}; std::cout << "Enter " << AMOUNT_TO_ENTER << " elements: "; for (size_t i{}; i < AMOUNT_TO_ENTER; ++i) { int val; std::cin >> val; elems.push_back(val); } std::cout << "\n\n\nBefore:\n"; for (auto i : elems) { std::cout << i << " "; } for (decltype(elems)::iterator itr = elems.begin(); itr != elems.end(); ++itr) { if (itr == elems.begin()) { continue; } else if (*itr + *(std::prev(itr)) == 10) { itr = elems.erase(itr); if (itr != elems.end()) { --itr; } } } std::cout << "\n\n\nAfter:\n"; for (auto i : elems) { std::cout << i << " "; } std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); std::cin.clear(); std::cin.get(); return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion