some tasks

This commit is contained in:
2025-05-03 01:17:58 +03:00
parent 6e8e69728e
commit 689b148736
5 changed files with 149 additions and 19 deletions
+45
View File
@@ -0,0 +1,45 @@
#include <list>
#include <iostream>
int main() {
std::list<int> l;
int n;
std::cin >> n;
while (n != 0) {
l.push_back(n);
std::cin >> n;
}
while (std::cin >> n) {
auto iter = l.begin();
if (n < 0) {
n = abs(++n);
if ((size_t)n >= l.size()) {
continue;
}
while (n--) ++iter;
l.erase(iter);
} else {
int tmp;
std::cin >> tmp;
--n;
while (n-- && iter != l.end()) ++iter;
l.insert(iter, tmp);
// l.insert();
}
}
for (auto& i : l) {
std::cout << i << std::endl;
}
return 0;
}