题解 | #牛牛的单向链表#

牛牛的单向链表

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;
}

全部评论

相关推荐

ArisRobert:统一解释一下,第4点的意思是,公司按需通知员工,没被通知到的员工是没法去上班的,所以只要没被通知到,就自动离职。就是一种比较抽象的裁员。
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务