Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int main1() {
- std::vector<int> v(5);
- for (int& x : v) std::cin >> x;
- v.insert(v.begin() + 2, 7);
- v.erase(v.begin() + 1);
- for (int x : v) std::cout << x << " ";
- std::cout << std::endl;
- return 0;
- }
- struct Node {
- int Data = 0;
- Node* Next = nullptr;
- explicit Node(int a) : Data(a) {}
- };
- int main() {
- Node* head = nullptr;
- int x = 0;
- Node* current = head;
- while (std::cin >> x && x != 0) {
- if (head == nullptr) {
- head = current = new Node(x);
- } else {
- current->Next = new Node(x);
- current = current->Next;
- }
- }
- for (Node* current = head; current != nullptr; current = current->Next) {
- std::cout << current->Data << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement