- 1、本文档共9页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- 5-3常见的酸--硫酸(5-3 common sulfuric acid - sulfuric acid).doc
- 5s管理法则(5S management rules).doc
- 5s检查100条050720(5S check 100 050720).doc
- 5定价策略(5 pricing strategy).doc
- 5年网编经验第一次晒简历(5 years of experience in network editing first sun resume).doc
- 5种家装防水吊顶面板的特点(5 types of home improvement waterproof ceiling panels features).doc
- 006_地狱观(006_ hell view).doc
- 5种中草药水提取液对灵芝三萜含量的影响(Effects of 5 extracts of Chinese herbal medicine on the content of three terpene in Ganoderma lucidum).doc
- 6.1 模板(6.1 templates).doc
- 06全口带入及问题(06 full mouth intake and problems).doc
- 基本面选股组合月报:大模型AI选股组合本年超额收益达6.60.pdf
- 可转债打新系列:安集转债,高端半导体材料供应商.pdf
- 可转债打新系列:伟测转债,国内头部第三方IC测试企业.pdf
- 联想集团PC换机周期下的价值重估.pdf
- 计算机行业跟踪:关税升级,国产突围.pdf
- 科技类指数基金专题研究报告:详解AI产业链指数及基金布局.pdf
- 计算机行业研究:AIAgent产品持续发布,关税对板块业绩影响较小.pdf
- 民士达深度报告:国内芳纶纸龙头,把握变局期崛起机遇.pdf
- 社会服务行业动态:全球首张民用无人驾驶载人航空器运营合格证落地,霸王茶姬冲击美股IPO.pdf
- 通信行业研究:特朗普关税令落地,长期看好国产算力链.pdf
最近下载
- 2025年贵州省毕节地区黔西县林泉镇招聘社区工作者考前自测高频考点模拟试题含答案解析.docx VIP
- 高中的地理学业水平考试知识点.(全).doc
- 冀教版一年级数学下册课件 第4单元 阳光课间活动.pptx VIP
- 学校劳动教育清单(含小学初中高中).docx
- 玻璃幕墙施工方案.doc VIP
- 水的奇幻旅程.pptx VIP
- 辅警岗位知识培训课件.pptx
- 专题03 遇到角平分线如何添加辅助线模型-2025年中考数学常见几何模型全归纳之模型解读与提分精练(江西专用)(原卷版).docx
- 23秋国开电大《比较初等教育》终结性考核大作业参考答案.pdf
- 【教案】交流与传承——东西文化碰撞中的艺术嬗变+教学设计高中美术人美版(2019)美术鉴赏.docx VIP
文档评论(0)