首页 > 解决方案 > 我必须解决 c 中的列表问题

问题描述

我们有一个蛋糕,上面有 n 个故事,放在银盘上。我们必须把它放在一个金色的盘子上,但是蛋糕太大了不能直接这样做,所以我们需要使用一个额外的盘子,一个青铜的。

#include <stdio.h>
#include <stdlib.h>

struct silver_plate
{
    int story;
    struct silver_plate *next;
};

struct silver_plate *head;
head=NULL;

struct golden_plate
{
    int story;
    struct golden_plate *next;
};

struct golden_plate *head1;
head1=NULL;


void push(struct silver_plate **head_ref,int story)
{
    struct silver_plate *next_node =
            (struct silver_plate*)malloc(sizeof(struct(silver_plate)));

    new_node->story=story;
    new_node->next=(*head_ref);

    (*head_ref)=new_node;
}

void move(struct golden_plate *head_ref)
{
    struct golden_plate *new_node =
            (struct golden_plate *)malloc(sizeof(struct(golden_plate)));

    new_node1->story=new_node->story;
    new_node1->next=(*head_ref1);

    (*head_ref1)=new_node1;
}

我希望输出是一个列表,排列在金盘上的 n 个故事。

标签: c

解决方案


推荐阅读