资源简介
西南交大 数据结构 实验代码 采用c编写的

代码片段和文件信息
#include
#include
#include
typedef struct Item{
double coef;
int expn;
struct Item *next;
}Item*Polyn;
#define CreateItem(p) p=(Item *)malloc(sizeof(Item));
#define DeleteItem(p) free((void *)p);
/************************************************************/
/* 判断选择函数 */
/************************************************************/
int Select(char *str)
{ char ch;
printf(“%s\n“str);
printf(“Input Y or N:“);
do{ ch=getch();
}while(ch!=‘Y‘&&ch!=‘y‘&&ch!=‘N‘&&ch!=‘n‘);
printf(“\n“);
if(ch==‘Y‘||ch==‘y‘) return(1);
else return(0);
}
/************************************************************/
/* 插入位置定位函数 */
/**************************************************************/
int InsertLocate(Polyn hint expnItem **p)
{ Item *pre*q;
pre=h;
q=h->next;
while(q&&q->expn { pre=q;
q=q->next;
}
if(!q)
{ *p=pre;
return(1);
}
else if(q->expn==expn)
{ *p=q;
return(0);
}
else
{ *p=pre;
return(-1);
}
}
/************************************************************/
/* 插入结点函数 */
/************************************************************/
void insert(Item *preItem *p)
{
p->next=pre->next;
pre->next=p;
}
/************************************************************/
/* 输入多项式 */
/************************************************************/
Polyn Input(void)
{
double coef;
int expnflag;
Item *h*p*q*pp;
CreateItem(h);//产生头结点
h->next=NULL;
printf(“input coef and expn(if end expn=-1)\n“);
while(1)
{
scanf(“%lf%d“&coef&expn); //输入多项式的系数和指数
if(expn==-1) break; //若指数为-1,表示输入结束
if(InsertLocate(hexpn&pp))//返回值非0表示插入新结点
{ CreateItem(p);
p->coef=coef;
p->expn=expn;
insert(ppp);
}
else if(Select(“has the same expnReplace older value?“))
pp->coef=coef; //指数相同,替换系数
}
return h;
}
/************************************************************/
/* 撤消多项式 */
/************************************************************/
void Destroy(Polyn h)
{
Item *p=h*q;
while(p!=NULL)
{
q=p;
p=p->next;
DeleteItem(q);
}
}
/************************************************************/
/* 输出多项式 */
/************************************************************/
void Output(Polyn hchar *title)
{
int flag=1;
Item *p=h->next;
printf(“%s=“title);
while(p)
{ if(flag) //表示是否是多项式的第一项
{ flag=0;
if(p->expn==0) printf(“%.2lf“p->coef);
else printf(“%.2lfx^%d“p->coefp->expn);
}
else
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-20 18:19 数据结构实验 - 副本\
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验一\
文件 10750 2013-12-06 09:41 数据结构实验 - 副本\数据结构 实验一\1.cpp
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验一\Debug\
文件 24595 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\Debug\1.obj
文件 33792 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\Debug\vc60.idb
文件 53248 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\Debug\vc60.pdb
文件 225353 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\Debug\数据结构 实验一.exe
文件 289776 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\Debug\数据结构 实验一.ilk
文件 4389 2013-09-15 11:28 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.dsp
文件 540 2013-09-15 11:28 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.dsw
文件 41984 2013-09-15 11:49 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.ncb
文件 48640 2013-09-15 11:49 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.opt
文件 2086 2013-09-15 11:48 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.plg
文件 1855488 2013-12-06 09:37 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.sdf
文件 6242 2013-12-06 09:37 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.vcxproj
文件 897 2013-12-06 09:37 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.vcxproj.filters
文件 143 2013-12-06 09:37 数据结构实验 - 副本\数据结构 实验一\数据结构 实验一.vcxproj.user
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验七\
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验七\Debug\
文件 36352 2013-12-13 20:46 数据结构实验 - 副本\数据结构 实验七\Debug\数据结构 实验七.exe
文件 345276 2013-12-13 20:46 数据结构实验 - 副本\数据结构 实验七\Debug\数据结构 实验七.ilk
文件 379904 2013-12-13 20:46 数据结构实验 - 副本\数据结构 实验七\Debug\数据结构 实验七.pdb
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验七\ipch\
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验七\ipch\数据结构 实验七-608c9497\
文件 2097152 2013-12-26 00:01 数据结构实验 - 副本\数据结构 实验七\ipch\数据结构 实验七-608c9497\数据结构 实验七-9fa7ecce.ipch
目录 0 2014-04-20 18:19 数据结构实验 - 副本\数据结构 实验七\数据结构 实验七\
文件 1986560 2013-12-26 00:02 数据结构实验 - 副本\数据结构 实验七\数据结构 实验七.sdf
文件 936 2013-12-12 23:32 数据结构实验 - 副本\数据结构 实验七\数据结构 实验七.sln
文件 11776 2013-12-26 00:02 数据结构实验 - 副本\数据结构 实验七\数据结构 实验七.suo
文件 14423 2013-12-13 20:46 数据结构实验 - 副本\数据结构 实验七\数据结构 实验七\1.cpp
............此处省略178个文件信息
相关资源
- DSP实验(10次实验有详细步骤)
- TPC-ZK系列USB学生实验指导书
- 虚拟仪器技术创新实验基地建设方案
- 实验三 消息中间件应用开发:Active
- 基于stm32f103ve的程序——跑马灯实验
- 周立功开发板ProASIC3实验-syn_FIFO代码
- 编译原理实验工具及参考源码(lex&
- dotnet 写字板 实验 源代码 不好请要不
- 类pascal语言编译器(编译原理实验)
- 数学建模实验报告(八个全)
- 数据结构年终考题范围和答案 耿国华
- 数值分析所有实验代码
- 数据结构 朱战力 习题解答 数据结构
- 数据结构课程设计 6 1 彩票系统
- 教学计划编制系统
- 数字逻辑与数字系统实验报告
- 大数(链表、数组)实现
- 多媒体综合设计报告(附作品)
- ubuntu9.10 可加载内核模块和字符设备驱
- 操作系统 LRU算法 实验报告 及 程序代
- 分页系统模拟实验 操作系统 课程设
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- 航空订票系统_数据结构课程设计
- 迈克尔逊干涉仪的调整与使用实验报
- 8259A中断控制实验
- 操作系统实验——虚存管理实验
- 广工操作系统实验
- 多项式求和(数据结构C 版)
- 尚观培训linux董亮老师关于数据结构的
评论
共有 条评论