记录我的数据结构(C语言)学习历程(2017年3月30号开始):
来源:互联网 发布:阿里云弹性ip 编辑:程序博客网 时间:2024/05/21 17:09
c
//main.c#include<stdio.h>#include<stdlib.h>#include<malloc.h>#include "List.h"int main(void){//char a[]="Error"; //int i;//FatalError(a);//List L,q;//CreateList(&L,8);//PrintList(L);//InsertH(6,L,L);//printf("%d\n",IsEmpty(L)); //q=Find(7,L); //i=q->Element;//printf("%d",i);//PrintList(L);//MakeEmpty(L); //DeleteList(L);//printf("%d\n",IsEmpty(L));List L1_1,L2_1,L3_1;ElementType n1,n2;printf("请输入第一个多项式的项数:");scanf("%d",&n1); printf("\n");printf("请输入第一个多项式的系数和指数:"); printf("\n");CreateList(&L1_1,n1);PrintList(L1_1);printf("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");printf("\n请输入第二个多项式的项数:");scanf("%d",&n2); printf("\n");printf("请输入第二个多项式的系数和指数:"); printf("\n");CreateList(&L2_1,n2);PrintList(L2_1);printf("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");L3_1=MultPolynomial(L1_1,L2_1);PrintList(L3_1);}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5//List.h#ifndef _LIST_H_typedef int ElementType;struct Node;typedef struct Node *PtrToNode;typedef PtrToNode List;typedef PtrToNode Position;/*struct Node{ElementType Element;Position Next;};*/struct Node{ElementType Cofficient;ElementType Exponent;Position Next;};void CreateList(List *L,int n);void PrintList(List L);List MakeEmpty(List L);void CreateEmptyList(List *L);int IsEmpty(List L);int IsLast(Position P,List L);Position Find(ElementType X,List L);void Delete(ElementType X,ElementType Y,List L);Position FindPrevious(ElementType X,List L);void Insert(ElementType X,ElementType Y,List L,Position P);void InsertH(ElementType X,ElementType Y,List L,Position P);void DeleteList(List L);Position Header(List L);Position First(List L);Position Advance(Position P);ElementType Retrieve(Position P);List MultPolynomial(List L1,List L2); #endif %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//List.c #include "List.h"#include<stdio.h>#include<stdlib.h>#include<malloc.h>/*struct Node{ElementType Element;Position Next;};*/void CreateList(List *L,int n){Position P,P1;int i;*L=(Position)malloc(sizeof(struct Node));(*L)->Next=NULL;P1=*L;printf("请输入%d对数据(以空格隔开):\n",n); //没问题 for(i=n;i>0;i--){//P=(Position)malloc(sizeof(struct Node)); //scanf("%d",&P->Element); //前插 //P->Next=(*L)->Next; //(*L)->Next=P;P=(Position)malloc(sizeof(struct Node));scanf("%d",&P->Cofficient);scanf("%d",&P->Exponent);P->Next=P1->Next; //后插 P1->Next=P;P1=P;}}void PrintList(List L){printf("已保存链表\n");Position P;P=L->Next;while(P->Next!=NULL){printf("%d ",P->Cofficient); //没问题 printf("%d ",P->Exponent);P=P->Next;} printf("%d ",P->Cofficient); //没问题 printf("%d ",P->Exponent);}void FatalError(char a[]){printf("%s",a); //没问题 }int IsEmpty(List L){return L->Next==NULL; //没问题 }int IsLast(Position P,List L){return P->Next==NULL; //没问题 }List MakeEmpty(List L){List q,p;p=L->Next;while(p!=NULL){ //没问题 q=p->Next;free(p);p=q;}L->Next=NULL;return L;}Position Find(ElementType X,List L){Position P;P=L->Next;while((P!=NULL)&&(P->Exponent!=X)) //没问题 {P=P->Next;}return P;}Position findPrevious(ElementType X,List L)</s
0 0
- 记录我的数据结构(C语言)学习历程(2017年3月30号开始)
- 记录我的数据结构(C语言)学习历程(2017年3月30号开始):
- 2017年1月22日,我打算开始记录自己接下来的学习、生活、工作历程。
- 开始记录我的学习历程
- 今天开始记录我的嵌入式学习历程
- 9月29日 开始用博客记录我的学习之旅 (产品)
- 记录我的学习历程
- 我的C语言历程
- 开始记录自己的学习历程
- 开始记录自己的学习历程
- 我的C语言学习历程:起步篇
- 我的C语言学习历程:进阶篇
- 我的C语言学习历程:图形篇
- 我的C语言学习历程:游戏篇
- 我的C语言学习历程:GUI篇
- 2017年12月3日,我,一个转行过来的Java程序员,要开启我的博客人生了,记录我的技术历程。
- 12天学好C语言——记录我的C语言学习之路(Day 3)
- C语言学习历程(十六)数据结构-单双向链表
- UIDynamicAnimator与UIDynamicBehavior(力学类动画)
- 【树莓派】RTC时钟模块安装教程第二部分:Rasbian(linux)下配置工作
- CSS零散要点
- 【树莓派】RTC时钟模块安装教程第三部分:启动自动时间矫正
- bootstrap table footerFormatter用法 统计列求和 sum、average等
- 记录我的数据结构(C语言)学习历程(2017年3月30号开始):
- 群消息这么复杂,怎么能做到不丢不重?
- 微信多点登录与QQ消息漫游架构随想
- 21. Merge Two Sorted Lists(第七周)
- 即时通讯协议设计选型
- 如何快速实现高并发短文检索
- 微信小程序真机预览跟本地不同的问题
- 同时支持mybatis,hibernate等技术的通用持久层实现思路
- 分解质因数