- 1、本文档共26页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
西电_C_面向象程序设计_软件技术基础_课后答案2
软件技术基础习题答案
习题3
四、1
int compare(SeqList*La,SeqList*Lb)
{
int i;
i=1;
while(i=La-lasti=Lb-Last La-data[i]==Lb-data[i])
i++;
if(i=La-lastjLb-last|| La-data[i]Lb-data[i]) return 1; //AB
if(iLa-lastj=Lb-last|| La-data[i]Lb-data[i]) return -1; //AB
if(iLa-lastjLb-last)
return 0; //A=B
}
四、2
(1)顺序表
int invert(SeqList*L)
{
int i=1;
datatype temp;
while(i=L-last/2)
{
temp=L-data[i];
L-data[i]=L-data[L-last-i+1];
L-data[L-last-i+1]=temp;
}
}
(2)链表
void invert (linklist*head)
{
linklist*p,*q,*r;
p=head-next;
q=p-next;
while(q!=NULL)
{
r=q-next;
q-next=p;
p=q;
q=r;
}
head-next-next=NULL;
head-next=p;
}
四、5
void mergelist(Linear_list*La,Linear_list*Lb,Linear_list*Lc)
{
Lc=(Linear_list*)malloc(sizeof(Linear_list)); //产生C表的头结点 头插法
Lc-next=NULL;
while(La-next!=NULLLb-next!=NULL) //La、Lb均非空
if(La-next-data=Lb-next-data)
{
p=La-next;
La-next=La-next-next;
insert(Lc,p);
}
else
{
p=Lb-next;
Lb-next=Lb-next-next;
insert(Lc,p);
}
while(La-next!=NULL)
{
p=La-next;
La-next=La-next-next;
insert(Lc,p);
}
while(Lb-next!=NULL)
{
p=Lb-next;
Lb-next=Lb-next-next;
insert(Lc,p);
}
}//O(Length(La)+Length(Lb))
void insert(Linear_list*Lc,Linear_list*p)
{
p-next=Lc-next;
Lc-next=p;
}//O(1)
四、8
void deleteFront(Link*s)
{
Link*p=s,*q;
while(p-next-next!=s)p=p-next;
q=p-next;
p-next=s;
free(q);
}
习题4
四、1
int symmetry(linklist*head,stack*s)
//具有头结点的单链表中存放有一个字符串,每个结点的数据域存放一个字符。
//head为单链表的头指针,s为栈的结构体指针
{
int n=length(head)/2;
linklist*p=head-next ;
datatype x;
for(int i=0;in;i++){
push(s,p-data);
p=p-next ;
}
if(length(head)%2==1) p=p-next;
while(p!=NULL){
x=pop(s) ;
if (x==p-data ) p=p-next;
else return 0;
}
return 1;
}
四、3
void delete(Stack*s)
{
Stack*temp;
datatype x;
InitS(temp);
while(!EmptyS(s))
{
x=Pop(s);
if(x!=m) Push(temp,x);
}
while(!Empty(temp))
Push(s,Pop(temp));
}
四、4
int corr
您可能关注的文档
- 药品注册现场核查及样程序与要求(试行).doc
- 药品管理法释义-药管理.doc
- 药品枕包机的使用方 选择方法.doc
- 药品补充申请表填表明.doc
- 药品营销中的沟通技.doc
- 药品行政处罚种类、据(药品生产、经营企业).doc
- 药品质量管理规范复.doc
- 药品采购入库制度程.doc
- 药学三基考试练习题答案.doc
- 药学专业知识二(药学、药物化学).doc
- 5000吨饲草颗粒加工扩建项目可行性研究报告模板-备案拿地.doc
- 加工蜂蜜营养制品项目可行性研究报告模板-立项备案.doc
- 耐火绝缘材料云母制品项目可行性研究报告写作模板-拿地申报.doc
- 火腿农产品精深加工建设项目可行性研究报告写作模板-申批立项.doc
- 年产3GW光伏切片3GW高效光伏组件项目可行性研究报告模板-立项备案.doc
- 高端智能装备制造生产项目可行性研究报告写作模板-拿地备案.doc
- 高端电子智造产业基地项目可行性研究报告模板-立项拿地.doc
- 年产3万片高灵敏空间组学检测芯片生产线项目可行性研究报告模板-立项备案.doc
- 建设年产20万套新能源汽车底盘技改项目可行性研究报告写作模板-申批备案.doc
- 25万吨年电解液项目可行性研究报告模板-立项备案.doc
文档评论(0)