CARVIEW |
Select Language
HTTP/2 200
date: Thu, 16 Oct 2025 05:08:30 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=c147c7255c222ebfdc72184ec7e23d75de1f7b5e3cd44d2d97f82d5f5e4ce622a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22WEATlIDPq9eaL-vN7k1MNoGWhTewFRBV%22%3B%7D; HttpOnly; Path=/
cf-ray: 98f509e6ff15ccbb-BLR
#include <iostream>using namespace std;struct node { int info; n - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct node {
- int info;
- node *next;
- };
- struct SinglyLinkedCircularList {
- node * head;
- node * tail;
- void init() {
- head = NULL;
- tail = NULL;
- }
- void insertFront(int x) {
- node * new_node = new node;
- new_node->info = x;
- new_node->next = NULL;
- if(head == NULL) {
- head = new_node;
- tail = head;
- tail->next = head;
- }
- else {
- new_node->next = head;
- head = new_node;
- tail->next = head;
- }
- }
- void insertBack(int x) {
- node * new_node = new node;
- new_node->info = x;
- new_node->next = NULL;
- if(head == NULL) {
- head = new_node;
- tail = head;
- tail->next = head;
- }
- else {
- tail->next = new_node;
- tail = new_node;
- tail->next = head;
- }
- }
- void deleteFront() {
- if(head != NULL) {
- if(head->next == head) {
- delete head;
- head = NULL;
- tail = NULL;
- }
- else {
- node * tmp = head;
- head = head->next;
- delete tmp;
- tail->next = head;
- }
- }
- }
- void deleteBack() {
- if(head != NULL) {
- if(head->next == head) {
- delete head;
- head = NULL;
- tail = NULL;
- }
- else {
- node * tmp = head;
- while(tmp->next != tail) {
- tmp = tmp->next;
- }
- delete tail;
- tail = tmp;
- tail->next = head;
- }
- }
- }
- void deleteNode(int x) {
- if(head != NULL) {
- if(head->info == x) {
- deleteFront();
- }
- else {
- node * tmp = head;
- node * prev = NULL;
- while(tmp != NULL && tmp->info != x) {
- prev = tmp;
- tmp = tmp->next;
- }
- if(tmp == tail) {
- deleteBack();
- }
- else {
- prev->next = tmp->next;
- delete tmp;
- }
- }
- }
- }
- void deleteNode(node * x) {
- if(head != NULL) {
- if(head == x) {
- deleteFront();
- }
- else {
- node * tmp = head;
- node * prev = NULL;
- while(tmp != NULL && tmp != x) {
- prev = tmp;
- tmp = tmp->next;
- }
- if(tmp == tail) {
- deleteBack();
- }
- else {
- prev->next = tmp->next;
- delete tmp;
- }
- }
- }
- }
- void print() {
- node * tmp = head;
- for(int i = 0; i < 10; i++) {
- cout << tmp->info << " --> ";
- tmp = tmp->next;
- }
- cout << endl;
- }
- };
- void popravi(SinglyLinkedCircularList slcl) {
- node * losh = slcl.tail->next;
- SinglyLinkedCircularList prva;
- prva.init();
- SinglyLinkedCircularList vtora;
- vtora.init();
- node * tmp = slcl.head;
- while(tmp != NULL and tmp != losh) {
- prva.insertBack(tmp->info);
- tmp = tmp->next;
- }
- while(losh != slcl.tail) {
- vtora.insertBack(losh->info);
- losh = losh->next;
- }
- vtora.insertBack(slcl.tail->info);
- prva.print();
- vtora.print();
- }
- int main() {
- SinglyLinkedCircularList slcl;
- slcl.init();
- int n;
- cin >> n;
- for(int i = 0; i < n; i++) {
- int x;
- cin >> x;
- slcl.insertBack(x);
- }
- slcl.tail->next = slcl.head->next->next->next->next->next->next;
- cout << slcl.tail->next->info << endl;;
- popravi(slcl);
- return 0;
- }
- // 108 105 110 107 101 100 108 111 111 112
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Crypto Accounts⭐⭐
Java | 4 min ago | 0.15 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 4 min ago | 0.15 KB
-
⭐⭐⭐Exchange Exploit⭐⭐
Java | 4 min ago | 0.15 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D G⭐⭐
Java | 4 min ago | 0.15 KB
-
⭐⭐⭐Make $15OO in 2O minutesV G⭐⭐
Java | 5 min ago | 0.15 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 5 min ago | 0.15 KB
-
⭐⭐⭐Profit Method⭐⭐
Java | 5 min ago | 0.15 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 5 min ago | 0.15 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand