1、元素添加

#include <stdio.h>
#include <stdlib.h> struct ListNode{
struct ListNode* next;
int data;
}; typedef struct ListNode node; void AddFront(node** head,node* newnode){
newnode->next = *head;
*head = newnode;
} void PrintList(node* head)
{
node* cur = head; if(cur == NULL)
printf("Empty List\n");
else{ while(cur != NULL)
{
if(cur->next == NULL)
printf("%d\n", cur->data);
else
printf("%d->", cur->data);
cur = cur->next; }
}
} int main()
{
node* head = NULL;
int data; int a[] = {,,,,};
int len = sizeof(a)/sizeof(int);
int i; for(i = ;i < len; i++ ){ data = a[i];
node* newnode = (node*)malloc(sizeof(node)); newnode->data = data;
newnode->next = NULL;
AddFront(&head,newnode); } PrintList(head);
return ;
}

随机推荐

  1. 将图标LOGO之类的图形图像转换成字体调用方法大全

    借鉴百度对此标题的评价: 使用字体图标的优势 字体图标除了图像清晰度之外,比位图还有哪些优势呢. 适用性:一个图标字体比一系列的图像(特别是在Retina屏中使用双倍大小的图像)要小.一旦图标字体加载 ...

  2. 阿里云AliYun表格存储(Table Store)相关案例

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. word遇到错误 使其无法正常工作 因此需要关闭word 是否希望我们立刻修复

    方法1: 网上找的方案: win10下按下快捷键win+R, 然后在里面输入 %appdata%\microsoft\templates ,确定,此时就会直接进入Word安装路径,在里面找到" ...

  4. Elasticsearch学习笔记 一

    本文版权归博客园和作者吴双本人共同所有 转载和爬虫请注明原文地址 www.cnblogs.com/tdws. 本文参考和学习资料 <ES权威指南> 一.基本概念 存储数据到ES中的行为叫做 ...

  5. Java Web开发——MySQL数据库的安装与配置

    MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RD ...

  6. JAVA中子类会不会继承父类的构造方法

    声明:刚刚接触java不久,如果理解有错误或偏差望各位大佬强势批判 java中子类能继承父类的构造方法吗? 父类代码: class Father { String name ; //就不set/get ...

  7. [解读REST] 6.REST的应用经验以及教训

    衔接上文[解读REST] 5.Web的需求 & 推导REST,上文根据Web的需求推导出了REST架构风格,以及REST的详细描述和解释.自从1994年以来,REST架构风格被用于指导Web架 ...

  8. 阿里巴巴Java开发规约插件p3c详细教程及使用感受

    阿里巴巴Java开发手册 在进入正题介绍这款插件之前,首先来谈一下<阿里巴巴Java开发手册>,2017年年初,首次公开的阿里官方Java代码规范标准手册可以说是引起了全民(IT界)代码规 ...

  9. Windows搭建wnmp

    1. 下载安装nginx: nginx官网下载地址:http://nginx.org/en/download.html 下载任一版本(我下载的是stable1.12.1版本)解压到D:\wnmp\ng ...

  10. LeetCode 561. Array Partition I (数组分隔之一)

    Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1 ...