欢迎来到天天文库
浏览记录
ID:45136418
大小:213.50 KB
页数:23页
时间:2019-11-10
《《习题答案及练习》PPT课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、计算机软件基础(第三版)第二章习题答案及练习Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.(a)O(n2)(b)O(n)(c)O(n3)3.O(n3)Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.8.统计输入数中正数和负数的
2、个数,输入0则结束。main(){intx,num1=0,num2=0;printf("inputnum");scanf("%d",&x);while(x!=0){if(x>0)num1=num1+1;elsenum2=num2+1;scanf("%d",&x);}printf("Positivenumis:%d",num1);printf("Negativenumis:%d",num2);}Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.
3、0.0.Copyright2004-2011AsposePtyLtd.LS28375^PR(1)L=P->link;28375^PRSL(2)R->data=P->data;28575^PRS9.对以下单链表分别执行下列各程序段,并画出结果示意图.Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.(3)R->data=P->link->data;28775^PRS(4)P->lin
4、k->link->link->data=P->data;25375^PRSEvaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.(5)T=P;while(T!=NULL){T->data=(T->data)*2;T=T->link;}S2^PR1014616(6)T=P;while(T->link!=NULL){T->data=(T->data)*2;T=T->link;}S2^PR1
5、01468Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.(7)P=(JD*)malloc(sizeof(JD));P->data=10;R->link=P;P->link=S;LS28375^RP10Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011As
6、posePtyLtd.(8)T=L;T->link=P->link;free(P);LS2837^PRT5(9)S->link=L;LS28375PR如果S->link==L则S所指向的结点为尾结点.Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0
7、.0.Copyright2004-2011AsposePtyLtd.12.(c)dcba13.(d)9,5,7,314.(a)T=T+1A[n]A[n-1]A[n-2]…….A[1]A[T]是栈顶元素T103040base15.bc,2#14图示Evaluationonly.CreatedwithAspose.Slidesfor.NET3.5ClientProfile5.2.0.0.Copyright2004-2011AsposePtyLtd.16.采用队列数据结构。要做的工作:开辟一个队列结构的线性表;设置一个队头指针和一个队尾
8、指针;有报到的或完成任务的,就排在队尾,需要工人做工时,从队头选派工人。17.入栈序列是(1、2、3),出栈序列是(2、1、3)19.i*(i-1)/2+j28.有n个叶子结点的哈夫曼树,其结点总数为2n-123.n24.1~2i-125.CDBF
此文档下载收益归作者所有