Mise en œuvre
rayan328
-
bichovski -
bichovski -
Hello,
Design of a network infrastructure and Active Directory on Windows Server 2003....
Design of a network infrastructure and Active Directory on Windows Server 2003....
Configuration: Windows 2003 server...enterprise edition
1 answer
-
```html
Comment implémenter des listes circulaires contiguës en C
```#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node *next; } Node; // Fonction pour créer un nouveau nœud Node* createNode(int data) { Node* newNode = (Node*)malloc(sizeof(Node)); newNode->data = data; newNode->next = newNode; // Pointeur vers lui-même return newNode; } // Fonction pour insérer un nœud dans la liste circulaire void insert(Node** head, int data) { Node* newNode = createNode(data); if (*head == NULL) { *head = newNode; } else { Node* temp = *head; while (temp->next != *head) { temp = temp->next; } temp->next = newNode; } newNode->next = *head; // Rendre circulaire } // Fonction pour afficher la liste circulaire void display(Node* head) { if (head == NULL) return; Node* temp = head; do { printf("%d ", temp->data); temp = temp->next; } while (temp != head); printf("\n"); } int main() { Node* head = NULL; insert(&head, 1); insert(&head, 2); insert(&head, 3); display(head); return 0; }