网站大量收购独家精品文档,联系QQ:2885784924

数据结构答案(Data structure answer).doc

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构答案(Data structure answer) Problem analysis and algorithm design First, a data structure is designed to represent an extra long integer, and then the algorithm can be designed. First, we use a header node with a ring chain to represent a non negative integer large, if for each number from the beginning is low, first to fourth, fifth to eighth... Each consisting of four bit numbers, followed on the list of the first and second nodes,... In the lack of MSB 4 stored in the last node list in the specified header node for -1 value. Such as: The big integer 587890987654321 can be represented by the following list of linked nodes head: In accordance with this data structure, you can start from the two header nodes, in turn corresponding to add, to find the required carrying descendants into the following operations. Specific implementation algorithm, please see the notes in the program. * program and program notes #includestdio.h #includestdlib.h #define HUNTHOU 10000 Typedef, struct, node{, int, data; Struct node *next; }NODE; / * * / define the list structure NODE *insert_after (NODE *u, int Num); / * insert a new NODE in the U node, its value is num*/ NODE *addint (NODE *p, NODE *q); / * complete addition operator returns a pointer to pointer * / *p+*q results Void printint (NODE *s); NODE *inputint (void); Void, main () { NODE, *s1, *s2, *s; NODE, *inputint (), *addint (), *insert_after (); Printf (Enter S1=); (s1=inputint); / * * / input addend Printf (Enter S2=); (s2=inputint); / * * / input addend Printf (S1=); printint (S1); putchar (\\\n\); / * * / display addend Printf (S2=); printint (S2); putchar (\\\n\); / * * / display number S=addint (S1, S2); / * and * / Printf (S1+S2=); printint (s); putchar (\\\n\); / * * / output } NODE *insert_after (NODE, *u, int, Num) { NODE *v; V= (NODE * malloc) (sizeof (NODE)); / * for a NODE*/ V-data=num; / * * / assignment U-next=v; / * insert a NODE*/ in the U node Return v; } NODE *addint (NODE *p, NODE *q) / * complete addi

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档