博文
带头结点单链表的实践(2008-03-27 02:45:00)
摘要:à1.数据结构及说明
typedef struct node
{
int number;
struct node *next;
}LNode, *LinkList;
à2.算法设计及说明
1)建立带头结点的单链表
首先申请空间建立头结点和第一个结点;q指向第一个结点,扫描输入第一个结点的数据;p指向q;while循环,当扫描输入的q的数据域的值不等于结束标志时,p指向新开辟的空间;再输入数据,用于下一次循环判断;p指向q,连接新的q结点;p跳到q上,准备连接下一个新的结点;当循环推出后,置尾结点指针域为空指针;最后返回头结点,链表建立完毕。
2)将值为x的结点插入一个按整数值递增的带头结点的单链表中,仍保持有序
在递增单链表中插入值,使之仍保持有序的关键在于:找到p结点的前驱结点q,然后在q之后插入s即可。
àError LINKLIST.C 43: Type mismatch in redeclaration of ‘list’
错因分析:list函数在主函数之后,应在主函数之前加以函数声明,或者直接将list函数放在主函数之前即可解决。
à在第一步的基础上,对源程序进行细化和修正时,对新插入的结点S,只给它申请了空间,并未把X的值赋给待插入结点的数据域,导致出来的结果是个随机值,运用了“打印输出”的调试思想,及时的发现了问题并予以改正。
àProgram begin to create the linklist!!
Please input the first data:
5
Please input the oter data:
16
Please input the oter data:
31
Please input the oter data:
-1
5 16 31
与预期结果吻合,成功实现了用“尾接法”带头节点(便于标识且操作统一)创建线性单链表,并顺次输出各个结点。
àProgram begin to create the linklist!!
......
【Study Wisdom】(2008-02-01 01:46:00)
摘要:1. This moment will nap, you will have a dream; But this moment study,you will interpret a dream. 2. I leave uncultivated today, was precisely yesterday perishestomorrow which person of the body implored. 3. Thought is already is late, exactly is the earliest time. 4. Not matter of the today will drag tomorrow. 5. Time the study pain is temporary, has not learned the pain islife-long. 6. Studies this matter, lacks the time, but is lacks diligently. 7. Perhaps happiness does not arrange the position, but succeeds mustarrange the position. 8. The study certainly is not the life complete. But, sincecontinually life part of - studies also is unable to conquer, what butalso can make? 9. Please enjoy the pain which is unable to avoid. 10. Only has compared to the others early, diligently diligently, canfeel the successful taste. 11. Nobody can casually succeed, it comes from the thoroughself-control and the will. 12. The time is passing. 13. Now drips the saliva, will become tomorrow the tea......
厚积薄发,有的放矢(2008-02-01 01:35:00)
摘要:厚积薄发,有的放矢――李开复博士给中国计算机系学生的建议 很多在校的大学同学问我们:“我今年还没有到毕业班,但我很想知道,如果将来我想申请Google中国工程研究院,现在应该如何让自己做好准备?”下面是Google中国总裁李开复博士和其他一些Google资深的华人工程师给广大同学的建议。 (1)练内功。不要只花功夫学习各种流行的编程语言和工具,以及一些公司招聘广告上要求的科目。要把数据结构、算法、数据库、操作系统原理、计算机体系结构、计算机网络,离散数学等基础课程学好。不妨试试Donald Knuth的Art of Computer Programming里的题目,如果你能够解决其中的大部分题目,就说明你在算法方面的功力不错了。 (2)多实战。通过编程的实战积累经验、内化知识。建议大家争取在大学四年中积累编写十万行代码的经验。 (3)求实干。不要轻视任何的实际工作,比如一些看似简单的编码或测试。要不懈追求对细节一丝不苟的实干作风与职业精神。 (4)不放弃数学。数学是思维的体操,数学无处不在。尤其当你对一些“数学密集型”的领域有兴趣,例如视频、图像处理等等,你需要使它成为你的利器。 (5)培养团队精神,学会与人合作。 (6)激励创新意识,不为书本和权威所约束。 (7)有策略地“打工”。在不影响学业的前提下,寻找真正有意义的暑期工作或兼职。去找一个重视代码的公司,在一个好的“老板”指导下完成真正会被用户使用的程序。不要急于去一个要你做“头”而独挡一面的地方,因为向别人学习,是你的目的。打工和找工作一样,“不要只看待遇和职衔,要挑一个你能够学习的环境,一个愿意培养员工的企业,一个重视你的专业的公司,最后,要挑一个好老板。” ......
