摘要: 使用链表计算两个大整数的和一道有意思的编程练习题:两个单链表(singly linked list),每一个节点里面一个0-9的数字,输入就相当于两个大数了。然后返回这两个数的和(一个新list)。这两个输入的list长度相等。 要求是:1. 不用递归。2. 要求算法在最好的情况下,只遍历两个list一次 ,最差的情况下两遍。下面是我的解法:#include #include #include #define MAX 32 // 列表长度struct Node { char num; struct Node *next;};void list_build(struct Node *... 阅读全文
posted @ 2013-06-30 22:43 Let it be! 阅读(2042) 评论(0) 推荐(0) 编辑