C 练习实例73

C 语言教程 · 2019-02-22 12:13:46

题目:反向输出一个链表。 

程序分析:无。

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include<stdio.h> #include<stdlib.h> #include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }LNode,*LinkList; LinkList CreateList(int n); void print(LinkList h); int main() { LinkList Head=NULL; int n; scanf("%d",&n); Head=CreateList(n); printf("刚刚建立的各个链表元素的值为:\n"); print(Head); printf("\n\n"); system("pause"); return 0; } LinkList CreateList(int n) { LinkList L,p,q; int i; L=(LNode*)malloc(sizeof(LNode)); if(!L)return 0; L->next=NULL; q=L; for(i=1;i<=n;i++) { p=(LinkList)malloc(sizeof(LNode)); printf("请输入第%d个元素的值:",i); scanf("%d",&(p->data)); p->next=NULL; q->next=p; q=p; } return L; } void print(LinkList h) { LinkList p=h->next; while(p!=NULL){ printf("%d ",p->data); p=p->next; } }

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

The Cult of the Amateur

The Cult of the Amateur

Andrew Keen / Crown Business / 2007-6-5 / USD 22.95

Amateur hour has arrived, and the audience is running the show In a hard-hitting and provocative polemic, Silicon Valley insider and pundit Andrew Keen exposes the grave consequences of today’s......一起来看看 《The Cult of the Amateur》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码