c - 我必须解决 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 个故事。
解决方案
推荐阅读
- javascript - 我想要按对象数组分组,例如 JavaScript 中的特定数组对象
- ios - Flutter App 无法在 IoS 模拟器上运行,运行器内有循环,并且 domain=NSPOSIXErrorDomain,code=63
- javascript - 我想从本地存储中删除特定对象
- azure - 关于 terraform 脚本行为
- java - 对 Microsoft Graph API 的 Java 请求执行正常,但返回 500
- ansible - 根据键过滤字典
- rust - 如何在 Rust 中使用任意文本作为函数名?
- cakephp - beforeSave 方法在 cakephp3 中不起作用
- javascript - Typescript 不允许在 URLSearchParams 中使用数字/数组
- c# - Jquery ajax 请求显示 json 对象而不是警报