题解 | #牛牛的单向链表#
牛牛的单向链表
https://www.nowcoder.com/practice/95559da7e19c4241b6fa52d997a008c4
#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node* next; } Node; int main() { int count, value; scanf("%d", &count); Node* head = (Node*)malloc(sizeof(Node)); Node* current = head; for (int i = 0; i < count; i++) { scanf("%d", &value); current->data = value; current->next = (Node*)malloc(sizeof(Node)); current = current->next; } current = head; while (current->next != NULL) { printf("%d ", current-> data); current = current->next; } return 0; }